Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a simple header for website - why can't I get the img to float all the way right?

Tags:

css

xhtml

I am making a very simple blog for my PHP project, but am having a simple problem. I can't get the image for my header to float all the way right. I have a banner with some text on the left, I have a 1px slice repeating across the width of whatever resolution may be chosen (ensuring the banner fills any screen). I would like the image to always render on the right edge of the screen, again, independent of screen resolution. But it is coming in at a fixed position. Here is what I have written:

HTML:

<div id="header">
    <img src="images/banner.jpg" alt="banner" title="Prairie"/>
    <img class="right_image" src="images/banner_right_image.jpg" alt="elavator" title="prairie elevator"/>
</div>

CSS:

#header {
    position: fixed;
    top: 0px;
    width: 100%;
    height: 120px;
    background: url(images/banner_right.jpg) repeat-x;
    z-index: 1;
}
#header.right_image {
    float: right;
    position: fixed;
    top: 0px;
    z-index: 1;
}

What is the issue here?

Thanks for any input.

like image 446
mrwienerdog Avatar asked Jan 28 '26 05:01

mrwienerdog


2 Answers

You should separate #header.right_image so that it is #header .right_image

Also remove position: fixed from #header.right_image

This works:

#header .right_image {
    float: right;
}

Example: http://jsfiddle.net/FTBWU/

like image 130
Jason Gennaro Avatar answered Jan 30 '26 22:01

Jason Gennaro


A link to your site would help!

I always throw at the top of my header:

 * { margin:0; padding:0}

You probably have padding or margins inherintly applied to your html or body tags depending on what browser you're using. Try that - and the is there a URL I can see the whole thing at?

like image 26
MadTurki Avatar answered Jan 30 '26 20:01

MadTurki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!