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 11-14-2012, 08:57 PM   PM User | #1
wonopon
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
wonopon is an unknown quantity at this point
Vertical Alignment of box divs

Hey, i'm trying to get three divs vertically aligned with each other properly.

Here is the div css styling:
Code:
#left-box
{
	float:left;
	border:1px solid green;
	width:300px;
}

#middle-box
{
	text-align:left;
	border:1px solid green;
	margin-left:380px;
	width:500px;
}

#right-box
{
	border:1px solid green;
	width:300px;
	position:relative;
	top:-82px;
	left:940px;

	top:-110px\9;
}
The problem happens with #right-box. When I use #left-box and #middle-box in my HTML, they both are vertically aligned. But when I use #right-box, it appears under the #left-box and #middle-box. I can solve this problem using position:relative and top, but that requires me to use css hacks for IE. Is there a cleaner and more proper way of doing this?

Thanks for your help everyone!
wonopon is offline   Reply With Quote
Old 11-14-2012, 10:46 PM   PM User | #2
Brandnew
New Coder

 
Join Date: Aug 2012
Posts: 50
Thanks: 0
Thanked 11 Times in 11 Posts
Brandnew is an unknown quantity at this point
Now i don't know if this will help but using span may help, i haven't checked this out in ie (idea came from http://stackoverflow.com/questions/2...splay-inline):

Code:
<html>
<head>
<style type="text/css">
#left-box
{
	float:left;
	border:1px solid green;
	width:300px;
}

#middle-box
{
	float:left;
	border:1px solid green;
	width:300px;
	margin-left:10px;
}

#right-box
{
	float:left;
	border:1px solid green;
	width:300px;
	margin-left:10px;
}
</style>
</head>
<body>

<span id="left-box">hi there</span>
<span id="middle-box">hi there</span>
<span id="right-box">hi there</span>

</body>
</html>
__________________
1 Corinthians 15:3-4 / Ephesians 2:8-9 - What or Who are you living for?
Brandnew is offline   Reply With Quote
Old 11-15-2012, 12:17 AM   PM User | #3
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello wonopon,
Have a look at 3 boxes here. Sorry for the aweful colors.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 11-15-2012, 12:19 AM   PM User | #4
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Quote:
Originally Posted by wonopon View Post
But when I use #right-box, it appears under the #left-box and #middle-box.
See the box model here. The box model says that whatever you put inside an element cannot be larger than that element. margin/padding/border all count when figuring width/height.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Users who have thanked Excavator for this post:
wonopon (11-15-2012)
Old 11-15-2012, 02:09 AM   PM User | #5
wonopon
New to the CF scene

 
Join Date: Nov 2012
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
wonopon is an unknown quantity at this point
Thanks guys so much for the help, it's just what I needed
wonopon is offline   Reply With Quote
Reply

Bookmarks

Tags
align, vertical align

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 11:19 PM.


Advertisement
Log in to turn off these ads.