09-07-08, 06:56 PM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
Div Problems
When you have 2 divs side by side Im floating one to the left and the other to the right how would I get the one to the right to align at the top instead of the center of the other div?
09-08-08, 08:32 AM
Community Liaison
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
You need to post the code so we can see what you are working with.
__________________
Jerry Broughton
Last edited by job0107; 09-08-08 at 08:37 AM .
09-10-08, 10:48 PM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
Here is my div functions
And here is my CSS
CSS Code:
div.half-title{
width :408px;
color :#b9b9b9;
font-family :Verdana, Arial, Helvetica, sans-serif ;
font-size :12px;
font-weight :bold ;
background-image :url ( "images/half_block_title.gif" ) ;
background-position :center ;
background-repeat :no-repeat ;
padding-bottom :1px;
padding-top : 1px;
float :left ;
}
div.half-content {
width :406px;
color :#333333;
font-family :Verdana, Arial, Helvetica, sans-serif ;
font-size :10px;
border-width :1px;
border-style :solid ;
border-color :#767676;
padding-bottom :1px;
float :left ;
}
div.nav-title{
width :213px;
color :#b9b9b9;
font-family :Verdana, Arial, Helvetica, sans-serif ;
font-size :12px;
font-weight :bold ;
text-align :right ;
background-image :url ( "images/nav_block_title.gif" ) ;
background-position :center ;
background-repeat :no-repeat ;
padding-bottom :1px;
padding-top : 1px;
top :auto ;
float :right ;
}
div.nav-content {
width :211px;
color :#333333;
font-family :Verdana, Arial, Helvetica, sans-serif ;
font-size :10px;
text-align :right ;
border-width :1px;
border-style :solid ;
border-color :#767676;
padding-bottom :1px;
float :right ;
}
Now what I want is nav-title and nav-content to align at the top with half-title and half-content instead of the middle. Any ideas?
Last edited by UnrealEd; 09-11-08 at 02:26 AM .
09-11-08, 07:11 PM
Community Liaison
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
It won't float because the over all width is 1242px.
The average available screen width on a 1024 X 768 screen is about 900 to 950px.
The float property floats the element to the edge of the available width.
If there isn't enough space to float it into, then it will put it on the next line.
So, you need to either make your elements narrower or give the screen more width.
The only problem with making the screen wider is, you can't.
But you can make the available screen width wider by using a div wrapper set to the desired width.
The drawback of using this solution is that the user will need to scroll the screen to see the whole width.
But it can be done like this:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
div.half-title{
width:408px;
color:#b9b9b9;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
background-image:url("images/half_block_title.gif");
background-position:center;
background-repeat:no-repeat;
padding-bottom:1px;
padding-top: 1px;
float:left;
}
div.half-content{
width:406px;
color:#333333;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px;
border:1px solid #767676;
padding-bottom:1px;
float:left;
}
div.nav-title{
width:213px;
color:#b9b9b9;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
text-align:right;
background-image:url("images/nav_block_title.gif");
background-position:center;
background-repeat:no-repeat;
padding-bottom:1px;
padding-top: 1px;
float:right;
}
div.nav-content{
width:211px;
color:#333333;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px;
text-align:right;
border:1px solid #767676;
padding-bottom:1px;
float:right;
}
</style>
</head>
<body>
<?php
function nav ( $title , $content , $ntitle , $ncontent ){
echo "<div class='half-title'> $title </div>
<div class='half-content'> $content </div>
<div class='nav-title'> $ntitle </div>
<div class='nav-content'> $ncontent </div>" ;
}
echo "<div style='width:1242px;'>" ;
nav ( "Half_title" , "Half_content" , "Title" , "Content" );
echo "</div>" ;
?>
</body>
</html>
__________________
Jerry Broughton
09-11-08, 07:14 PM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
There is no problem with the float on the left and right its not lining up where I want it to at the top of the page.
09-11-08, 07:25 PM
Community Liaison
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
I guess I don't understand.
You are going to have to explain it better.
__________________
Jerry Broughton
09-11-08, 07:35 PM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
I have attached a file on what it looks like, but I want "Navigation" to be up where it says "Hello" just on the right side of the page, it is on the right side, just not at the top where I want it.
09-11-08, 07:49 PM
Community Liaison
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Oh, you mean like this:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style> div.half-title{ width:408px; color:#b9b9b9; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; background-image:url("images/half_block_title.gif"); background-position:center; background-repeat:no-repeat; padding-bottom:1px; padding-top: 1px; padding-left:10px; float:left; } div.half-content{ width:406px; color:#333333; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; text-align:left; border:1px solid #767676; padding-bottom:1px; float:left; } div.nav-title{ width:213px; color:#b9b9b9; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold; text-align:right; background-image:url("images/nav_block_title.gif"); background-position:center; background-repeat:no-repeat; padding-bottom:1px; padding-top: 1px; padding-right:10px; float:right; } div.nav-content{ width:211px; color:#333333; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px; text-align:right; border:1px solid #767676; padding-bottom:1px; float:right; } </style> </head> <body><?php function nav ( $title , $content , $ntitle , $ncontent ){ echo "<div class='half-title'> $title </div> <div class='nav-title'> $ntitle </div> <br style='clear:both;' /> <div class='half-content'> $content </div> <div class='nav-content'> $ncontent </div>" ; } nav ( "Half_title" , "Half_content" , "Title" , "Content" ); ?> </body> </html>
__________________
Jerry Broughton
09-13-08, 03:50 PM
Wannabe Coder
Join Date: Apr 2005
Location: Knob Noster, Mo
Posts: 228
Thanks: 1
Thanked 0 Times in 0 Posts
That just made my whole layout not look right and it still didn't fix my problem.
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off