Reply
How to float two backgrd images inside a div?
Old 01-07-2006, 01:45 AM How to float two backgrd images inside a div?
Average Talker

Posts: 25
I am trying to place one background-image to the left side and another background-image to the right side of a div container using the float attribute. Am able to float one background-image to one side of the containing div when I assign it in a h1 as follows:
#header h1 {
margin: 0;
padding: 20px 5px 45px 100px;
color: #00008B;
background: url(../images/sphinx-logo.jpg) no-repeat top left;
font: 200% Arial, Helvetica, sans-serif;
Is there a way to get this to work for two background-images with one being floated to the left and the other to the right?

If not I will try using the img method using floats instead.

Appreciate your help.

Steve
stevefarillo is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 01-07-2006, 03:21 AM
King Spam Talker

Posts: 1,004
Location: Manchester, UK
Hi stevefarillo,

technically speaking, you are not 'floating' your background images - floating is something else.

I would wrap your div in another div with a background image positioned to the other side:
HTML Code:
<div id="left">
  <div id="right">
  </div>
</div>
so #left would have background: url(../images/sphinx-logo.jpg) no-repeat top left;
amd #right would have background: url(../images/sphinx-logo.jpg) no-repeat top right;
gringo is offline
Reply With Quote
View Public Profile Visit gringo's homepage!
 
Old 01-07-2006, 10:57 AM
Average Talker

Posts: 25
Gringo,

Gave that approach a try but it did not work at all using background-images. Can only get a single background-image to work right with it placed in a h1, h2,..., p, etc. element in a div id, otherwise the image dosen't appear at all.

An important note I didn't tell you about in my original post!
Also, I have another background-image in the #header div, which is before the background-image I am placing to the left in the #header h1. Here is the CSS code for entire header section of my page. This was done so that the logo image to the left would appear on top of the 1st background-image.
/* Header */
#header {
border-bottom: 3px solid #00008B;
background: #6495ED url(../images/header-bg.jpg) no-repeat top left;

}
#header h1 {
margin: 0;
padding: 20px 5px 45px 100px;
color: #00008B;
background: url(../images/sphinx-logo.jpg) no-repeat top left;
font: 200% Arial, Helvetica, sans-serif;
}

I think I will try removing the 1st background-image and adding the two image to the left & right and see what happens. If that does it, then I will have to go without having a nice gradient effect in my header bar.

Steve
stevefarillo is offline
Reply With Quote
View Public Profile
 
Old 01-07-2006, 12:31 PM
Average Talker

Posts: 25
No luck at all getting that second background-image to display in my browser. Tryed it without the 1st background-image, tryed it several different ways using the technique posted by Gringo.

No matter what I try the 2nd background-image never appears. lol
Dosen't make any sense to me.

Have any ideas on what is wrong?
Must be something simple I am overlooking.

CSS layout:
/* Header */
#header {
border-bottom: 3px solid #00008B;
background: #6495ED url(../images/header-bg.jpg) no-repeat top left;
}
#header h1 {
margin: 0;
padding: 20px 5px 45px 100px;
color: #00008B;
background: url(../images/sphinx-logo.jpg) no-repeat top left;
font: 200% Arial, Helvetica, sans-serif;
}
#header2 {
margin: 0;
padding: 0;
background: url(../images/pyramids.gif) no-repeat top right;
}


html coding
<body>
<div id="wrap">

<div id="header">
<h1>FullMoonSphinx.net</h1>
<div id="header2"></div>

</div>

<div id="content">
<h2>Hathor: the perfect face reveals the pentagon</h2>
<div class="gutter">... content goes here ...</div>
</div>

<div id="sidebar">
<div class="gutter">... sidebar goes here ...</div>
</div>

<div id="footer"></div>

</div> <!-- end #wrap -->

</body>
Steve
stevefarillo is offline
Reply With Quote
View Public Profile
 
Old 01-08-2006, 08:03 AM
King Spam Talker

Posts: 1,004
Location: Manchester, UK
I think wrapping the <h1> in the header2 div might work:

HTML Code:
<div id="header">
<div id="header2">
<h1>FullMoonSphinx.net</h1>
</div>
</div>
gringo is offline
Reply With Quote
View Public Profile Visit gringo's homepage!
 
Old 01-08-2006, 03:58 PM
vangogh's Avatar
Post Impressionist

Latest Blog Post:
How Do You Define SEO?
Posts: 8,621
Name: Steven Bradley
Location: Boulder, Colorado
Try assigning a width and height to #header 2. If that doesn't work put a &nbsp; inside the div. Sometimes when a div is empty the browser will close it up unless a width and height are explicitly specified. Not sure it that will be your solution, but worth a try.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 01-11-2006, 01:16 PM
Average Talker

Posts: 25
Tryed using both of your suggestions, but it turns out that background images are limited in this case anyways. I can do it by creating 3 separate divs with floats and assigning the two images in the html markup, but it breaks down to easily when the h1 title is resized.

So I decided to do without the second image and keep my layout user & search engine friendly.

Thanks for the help!

Last edited by stevefarillo : 01-11-2006 at 01:33 PM.
stevefarillo is offline
Reply With Quote
View Public Profile
 
Old 01-11-2006, 01:43 PM
vangogh's Avatar
Post Impressionist

Latest Blog Post:
How Do You Define SEO?
Posts: 8,621
Name: Steven Bradley
Location: Boulder, Colorado
Sorry the suggestions didn't work, but glad you were able to come up with a solution.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to How to float two backgrd images inside a div?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.17540 seconds with 13 queries