Skip navigation
Currently Being Moderated

Align image with h1 header

Sep 9, 2012 1:32 AM

Problem with align image with h1 header. I want an image on the same line as the H1 tag or any Header tag.

I managed to do so but what if I do not want middle but say 10px from top or bottom from the image.

Any place along with left and right position.

I am tied into the image as the H1 tag wraps around it and only have top, middle, bottom or similiar as options.

 

If it wasn't for the image being on the same line then it would be easy to position the text.

 

Question: Is there anyway that the Header tags can be position precisely with an image on the same line?

** I have search and search but it seems not but prove me wrong   : )

 

I tried to post the code but it won't display correctly here.

Go here then view source to my 1st attempt where I wrap the image inside a H1 tag: http://davidswebsite.com/test/test_page1.html

 

Update - Possible solution:

After spending yet more time I came up with this other solution where I can move the Header to any position. It looks the same using Adobe BrowserLab in IE7 & IE8 and Chrome 18

I had to use VMWare where I have XP installed with IE6 as Adobe BrowserLab is not showing IE6 right now.

Many complaints over the months about problems with it.

http://forums.adobe.com/community/cslive/browserlab

 

Here is the 2nd attempt using a wrapper with 2 divs inside the main container.

http://davidswebsite.com/test/test_page2.html

 

Here is a screenshot of IE6 using test_page2.html that shows a "t" in the .container for some reason - any ideas?

Shows fine in IE7 & 8 and Firefox 8 and Chrome 18

ie6.gif

 

 

 

David

 

 
Replies
  • Currently Being Moderated
    Sep 9, 2012 3:48 AM   in reply to davidhelp

    Hi David -

     

    Try floating your image left and  playing with the margins.

     

    You can lose the stray "t" in IE6 by adding a space in front of the link closing tag like this

     

      <p><a href="test_page1.html">Link to 1st attempt </a></p>

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2012 10:47 AM   in reply to davidhelp

    Try these changes to your CSS:

     

    .header {

    background-color: #FFDC93;

    padding: 0;

    margin: 0;

    float: left; /**REMOVE THIS**/

    width: auto;

    overflow:hidden; /**for float containment**/

    }

     

    h1 {

    font-size: 3em;

    font-family: Georgia, "Times New Roman", Times, serif;

    color: #000;

    padding: 0;

    margin: 1.08em 0 0 0.12em;

    float:right;

    }

     

    I wouldn't be too concerned about IE6 as it is an obsolete browser used by fewer than 1% of internet users.

     

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2012 7:52 PM   in reply to davidhelp

    The easiest way to do this is something like this:

     

    1) First your HTML code:

     

     

    <div id="masthead">

        <div id="logo"><img alt="pc,gif" src="http://davidswebsite.com/test/pc.gif" />

        </div>

        <div id="header">

    <h1> Web Page Title</h1>

        </div>

    </div>

    <div id="container">

        <div id="left_col">This is your left side bar

        </div>

        <div id="page_content">This is your page content

        </div>

    </div>

    <div id="footer">This is your footer

    </div>

     

    2) Now your relevant CSS without any formatting:

     

     

    body {

        margin: 0;

        padding: 0;

    }

     

    #masthead {

        min-width: 600px;

    }

     

    #logo {

        float: left;

        width: 200px;

    }

     

    #header {

        margin-left: 200px;

    }

     

    #container {

        clear: both;

        min-width: 600px;

    }

     

    #left_col {

        float: left;

        width: 200px;

    }

     

    #page_content {

        margin-left: 200px;

    }

     

    #footer {

        clear: both;

    }

     

    3) Now all you need to do is enter your background color and all that in the CSS given above.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points