This is a discussion on "Trying to align a div in a wrapper" within the Web Page Design section. This forum, and the thread "Trying to align a div in a wrapper are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Trying to align a div in a wrapper
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
||||
|
Trying to align a div in a wrapper
I am trying to align a div which holds an image but it is not centering.
I have an image i use as a background image which gives the impression the page content is a piece of paper with shadows underneath. I want to add the content in the actual page and in IE it lines up perfectly but if Firefox it's not. In Firefox the div is aligning to the edge of the background image. If anyone knows how i can align the content centered in both browsers I would be grateful The background image is 841px by 5px. I've included a zipped folder with the css file, image and html file if people want to see what is going on. Here is the CSS for the layout so far
|
|
|
|
||||
|
Re: Trying to align a div in a wrapper
I had the same problem (I probably read the same web page as you did). I eventually made a .gif with the background color filled in, instead of just side/corner/bottom shadow, and they were exactly the same KB in size!
So -- Try doing a graphic with both the shadow and the background. I bet if your background is a solid color, it take no more memory and save a ton of positioning hassles. I did it in two parts, a shadowed background 1px high and a bottom 7px high, with the corner and bottom shadow. Have a look http://www.dhreport.com/test_interactive/waist_hip.php Last edited by masonbarge; Feb 19th, 2007 at 21:21. |
|
||||
|
Re: Trying to align a div in a wrapper
I misunderstood, I thought that it was the shadow giving you problems.
FF and IE are both hard with floats and centers in a nested div situation. Actually, I'm surprised: margin: 0 auto has always worked with FF but not IE. Have you tried adding "text-align: center"? to .content and then text-align:left to the inner boxes? To tell you the truth, to get cross-browser compliance, I just approximate left margins to internal boxes (especially in float situations) and have alternate style for other browsers if there are differences. |
|
||||
|
Re: Trying to align a div in a wrapper
I got it working now
I had to use this
I did have to set the inner div to text-align: left though |
|
|||
|
Re: Trying to align a div in a wrapper
I wish I had seen this post two weeks ago before I finally figured this out for myself this morning.
http://www.betagammachapter.com/welcome.html |
|
||||
|
Re: Trying to align a div in a wrapper
margin: 0 auto works in all browsers. However, if you are still supporting IE5.5 then you need to add text-align: center in the parent element.
How to center your site horizontally <body> can be used to style too! |
|
||||
|
Re: Trying to align a div in a wrapper
For IE, centering block elements by auto-margins only works starting from version 6 and only when in "standard compliant" mode. I still use text-align for IE 6, just in case of quirk problems.
|
![]() |
| Tags |
| center, div, firefox, images |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Wrapper problem | goldy | Web Page Design | 2 | May 30th, 2008 19:11 |
| wrapper not detecting content | saltedm8 | Web Page Design | 4 | Apr 6th, 2008 22:31 |
| overhanging an imge in a wrapper div | lister110 | Website Planning | 1 | Jan 13th, 2008 18:24 |
| [SOLVED] CSS wrapper affecting body | Joolsd186 | Web Page Design | 7 | Dec 31st, 2007 19:11 |
| My navigation breaks my wrapper. | tigerslicer | Web Page Design | 6 | Sep 10th, 2007 10:58 |