Click here to Skip to main content
14,099,286 members
Rate this:
 
Please Sign up or sign in to vote.
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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[^]
   
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?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

If you don't want to use Bootstrap, you can just use Flexbox directly:
A Complete Guide to Flexbox | CSS-Tricks[^]
<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>
@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[^]
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190518.1 | Last Updated 18 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100