CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
CSS Combat
fluid with div
nidhins
Permalink to comment
#
May 2009
hi everyone
can anyone help me in creating a fluid width div whose width changes exactly like the body width...
thanks
Nidhin
chazzwick
Permalink to comment
#
May 2009
if you want the width of the div to be the same as the body all you have to do is not declare a width on the div, it will inherit width from the body.
AshtonSanders
Permalink to comment
#
May 2009
And if you want the div to be 50px from both sides of the screen at all time:
margin: 0 50px;
And if you want the div to be 5% from both sides of the screen at all time:
margin: 0 5%;
(Since I just finished doing that, you can see an example (of shameless advertising :D ) here: http://cssvideos.com/)
nidhins
Permalink to comment
#
May 2009
thanks for the help....
Add a Comment
can anyone help me in creating a fluid width div whose width changes exactly like the body width...
thanks
Nidhin
And if you want the div to be 5% from both sides of the screen at all time:
(Since I just finished doing that, you can see an example (of shameless advertising :D ) here: http://cssvideos.com/)