Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-07-2013, 02:10 PM   PM User | #1
Windbrand
New Coder

 
Join Date: Sep 2011
Posts: 44
Thanks: 4
Thanked 0 Times in 0 Posts
Windbrand is an unknown quantity at this point
Sections with equal dynamic width

How do I set up a container of dynamic width, but each section in it has equal width so that they all resize at the same time with the container?

For example:

Code:
.container{
width:80%; /*of viewport*/
}
.section{
position:relative;
float:left;
width: 80%/6; <---- pseudo code
}
There are 6 equal sections. For example if the .container is 900px, then each .section would be 150px. If .container is 1200px, then each .section would be 200px.
Thanks.
Windbrand is offline   Reply With Quote
Old 03-07-2013, 03:03 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,364
Thanks: 18
Thanked 347 Times in 346 Posts
sunfighter is on a distinguished road
You do get your hands slapped for position:relative; around here.

Code:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<style type="text/css">
.container{
width:80%;
height: 400px;
background-color: blue;
}
.section{
float:left;
width: 13%;
height: 350px;
background-color: green;
margin-right: 5px;

}
</style>
</head>

<body>
<div class="container">
<div class="section"></div>
<div class="section"></div>
<div class="section"></div>
<div class="section"></div>
<div class="section"></div>
<div class="section"></div>
</div>
</body>
</html>
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:32 AM.


Advertisement
Log in to turn off these ads.