Click here to Skip to main content
15,900,815 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So i'm building an portfolio for myself, but I just cannot put the second h2 tag in the center of the div..

This is what the end result should look like:
Photo — imgbb.com[^]

This is the original photo:
face — imgbb.com[^]

I hope someone can help

What I have tried:

/*Index.html*/

<!DOCTYPE html>
<meta charset="UTF-8">
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
    <link href='https://fonts.googleapis.com/css?family=Raleway' rel='stylesheet'>
    <title>Debaveye Elias</title>
  </head>
  <body>
    <div class="head">
      <img src="images/face.jpg" id="face" alt="">
      <h1 class="head">Debaveye Elias</h1>
      <h2 class="head" >A C# software developer</h2>
    </div>
  </body>
</html>



/*Style.css*/

@import url(https://fonts.googleapis.com/css?family=Raleway);

div.head img#face {
  width: 450px;
  height: 450px;
}
div.head {
  background: rgba(187, 200, 133, 1);
  margin: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
  position: center;
  width: 1088px;
  height: 450px;
}
div.head h1{
  display: inline-block;
  font-family: Raleway;
  color: #FFF;
  font-size: 70px;
  overflow: hidden;
  padding-left: 65px;
  padding-bottom: 187px;
  font-weight: lighter;
}

div.head h2 {
  display: inline-block;
  margin-top: 0px;
  font-family: Raleway;
  color: #000;
  font-size: 50px;
  font-weight: lighter;
}
Posted
Updated 18-Feb-19 4:49am
Comments
MadMyche 15-Feb-19 20:40pm    
Don't have an IDE to work with this, but I would look at using a float on the image tag
Member 14151982 16-Feb-19 5:15am    
You don't need an IDE to program html xD.
the point is, everything is in place, except the part that says "A c# software developer".

This is an online html editor. Here is where you can see everything together: https://codesandbox.io/s/vy8qwz95xl
MadMyche 16-Feb-19 8:02am    
Which I don't intend to do on my phone
Member 14151982 16-Feb-19 8:13am    
understandable

I would suggest to use Bootstrap Grid system, add one row and two columns, then use my-auto class on the second column to auto adjust its height based on the image height on first column. Some benefits are the page should display correctly in most browser and the content auto adjust to fit based on browser width/resolution. here is the demo cp demo[^], here the sandbox: static - CodeSandbox[^]


Reference
Grid system · Bootstrap[^]
 
Share this answer
 
Comments
Member 14151982 17-Feb-19 6:19am    
Well thank you very much :D but one thing, for example, the header is now the full width of the page, how do i change it so it is a specific amount?
If you don't want to use Bootstrap, you can just use Flexbox directly:
A Complete Guide to Flexbox | CSS-Tricks[^]
HTML
<article class="head">
	<img src="https://i.ibb.co/WGszpH9/face.jpg" id="face" alt="" />
	<header>
      <h1>Debaveye Elias</h1>
      <h2>A C# software developer</h2>
	</header>
</article>
CSS
@import url(https://fonts.googleapis.com/css?family=Raleway);

.head {
    font-family: Raleway;
    background: rgba(187, 200, 133, 1);
    margin: auto;
    display: flex;
    align-items: center;
}
.head > img {
    width: 30%;
    margin-right: 20px;
}
.head h1 {
    color: #FFF;
    font-size: 70px;
    font-weight: lighter;
    margin: .2em 0;
}
.head h2 {
    color: #000;
    font-size: 50px;
    font-weight: lighter;
    margin: .2em 0;
}

Demo[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900