float:left changes width of div (Full Version)

All Forums >> [Web Development] >> Cascading Style Sheets and Accessibility



Message


Rin -> float:left changes width of div (10/24/2008 5:10:12)

Hello everyone!

I've gotten myself stuck, and I was hoping somebody here could help me.

I have a page who's 'main' section of the body is divided into 2 parts, the content on the left, and a side bar on the right (common layout). However, I cannot get the sidebar to sit next to the content unless the side bar comes before the content in the HTML; which I would like to avoid for accessibility reasons. The only other option I am aware of is to have the content section floated as well. I have tried this, but when I add float:left to the style sheet the div floats, but the width of the div also changes.

I only have access to FF at the moment, so I don't know how it is behaving in other browsers.

Also, using FireBug, I have cut out all of the extra rules from parent tags, and it doesn't have any effect on the problem.

So there is my problem, and my question is:

Is there a way to counter this, without setting a specific width for the div's?

heres a link if you need it (it's no where near finished):
http://www.afbu.org/theme.html




Tailslide -> RE: float:left changes width of div (10/24/2008 6:31:37)

If you're floating a div then you MUST set a width for it. You can however use % insead of PX or EMs if you prefer.

If you fail to set a width for a float (unless it's implicit i.e. a photo) then some browsers will shrink the div to fit the content - which sounds like what's happening to you - others will take a wild guess... not a good thing!

I'd go for floating both and giving both a width in % - it's the most reliable way.




Rin -> RE: float:left changes width of div (10/24/2008 10:09:10)

Thank you,
I thought it defaulted to 100% of it's parent, and based on that I was trying to use margins to set make space for them to sit side by side.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625