CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 23rd, 2013, 11:33 PM
psychobyte psychobyte is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2009
Posts: 116 psychobyte User rank is Sergeant Major (2000 - 5000 Reputation Level)psychobyte User rank is Sergeant Major (2000 - 5000 Reputation Level)psychobyte User rank is Sergeant Major (2000 - 5000 Reputation Level)psychobyte User rank is Sergeant Major (2000 - 5000 Reputation Level)psychobyte User rank is Sergeant Major (2000 - 5000 Reputation Level)psychobyte User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 19 h 46 m 52 sec
Reputation Power: 26
Fitting horizontal divs in one row

Hi,

I always run into this problem and don't know the right way to get around it.

I typically have a parent fixed width div and several child divs inside. I'd like them to align them into one row. So I typically, just divide the widths of the children equally to all fit into the parent div. This typically works but, if I then add a right/lift border the last child div moves to the second row.

Is there a smarter way of doing this?

Reply With Quote
  #2  
Old January 23rd, 2013, 11:55 PM
DonR DonR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 463 DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 29722 Folding Title: Starter FolderFolding Points: 29722 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 2 Days 7 m 12 sec
Reputation Power: 216
borders are added onto the outside width of an item, so, if you have a div that is 300px wide and you then add a 1 px left and right border, you have now made that div 302px wide.

Reply With Quote
  #3  
Old January 24th, 2013, 12:19 AM
Catacaustic's Avatar
Catacaustic Catacaustic is offline
Code Monkey V. 0.9
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2005
Location: A Land Down Under
Posts: 1,885 Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 14 h 47 m 3 sec
Reputation Power: 1798
A good way to do this so it's a bit more friendly then risking if things are one pixel out is to add an inner div tag, then style the outer tag for the full width, and apply any borders or spacing to the inner div. This keeps each area at the correct width, nothing overflows and you're able to set up any margins/padding/borders that you want without risking the layout.

As an example...

Code:
<div class="outer_div"><div class="inner">Content goes in here</div></div>


Code:
.outer_div {
    width: 25%;  // Assuming 4 equal spaced items
    float: left;
}
.outer_div .inner {
    margin: 0 2px;
    border: 1px solid #000000;
    padding: 5px;
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Fitting horizontal divs in one row

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap