PDA

View Full Version : [CSS] float



NeoDreamer
April 23rd, 2007, 12:42 AM
http://img242.imageshack.us/img242/2412/kirnt6.th.gif (http://img242.imageshack.us/my.php?image=kirnt6.gif)

I'm trying to get the user and nav div's to go side by side, but the user div is squashed downward and isn't as wide as I set it.



#page {
margin: auto;
width: 1000px;
}

#nav {
background: #444d45; // black
width: 800px;
height: 45px;
}

#user {
float: right;
background: #444d45; // black
width: 200px;
height: 45px;
}

..........




<div id="page">

<div id="nav">
nav
</div>

<div id="user">
user
</div>

.....

icio
April 23rd, 2007, 07:29 AM
Try puting the <div id="user"> first.

NeoDreamer
April 23rd, 2007, 09:18 AM
http://img180.imageshack.us/img180/9309/kir2va0.th.gif (http://img180.imageshack.us/my.php?image=kir2va0.gif)

That helped the floating problem but not the width problem. Clearly nav is not 800 px and user is not 200 px.

bwh2
April 23rd, 2007, 09:24 AM
post your full HTML including DOCTYPE

NeoDreamer
April 23rd, 2007, 01:45 PM
http://img49.imageshack.us/img49/767/kir3vo6.th.gif (http://img49.imageshack.us/my.php?image=kir3vo6.gif)

So I did some work since the previous post. Basically, my page is divided into two columns (Col 1 = 800px, Col 2 = 200px). For some reason, the right column's rows are not filling up all the space.



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>DesignAxe</title>

<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="description" content="ok" />
<meta name="keywords" content="ok" />
<meta name="author" content="ok" />

<style type="text/css" media="all">@import "style.css";</style>
</head>
<body>
<div id="page">

<div id="user">
user
</div>

<div id="nav">
nav
</div>

<div id="user-shadow">
user-shadow
</div>

<div id="nav-shadow">
nav-shadow
</div>

<div id="side">
side
</div>

<div id="main">
main
</div>

<div id="bottom">
<div id="aux-shadow">
aux-shadow
</div>

<div id="footer-shadow">
footer-shadow
</div>

<div id="aux">
aux
</div>

<div id="footer">
footer
</div>
</div>

</div>
</body>
</html>



body {
font-family: Arial, Helvetica, Verdana, Sans-serif;
font-size: 62.5%;
color: #666666;
background: #ffffff;
margin: 0px;
}

#page {
margin: auto;
width: 1000px;
}

#nav {
margin-right: 200px;
background: #444d45; // black
width: 800px;
height: 45px;
}

#user {
float: right;
background: #444d45; // black
width: 200px;
height: 45px;
}

#nav-shadow {
margin-right: 200px;
background: #d1d1d1; // gray
width: 800px;
height: 10px;
}

#user-shadow {
float: right;
background: #b1b5c4; // gray-blue
width: 200px;
height: 10px;
}

#main {
margin-right: 200px;
background: #ffffff; // white
width: 800px;
}

#side {
float: right;
background: #e6ebff; // blue
width: 200px;
}

#footer-shadow {
margin-right: 200px;
background: #d1d1d1; // gray
width: 800px;
height: 10px;
}

#aux-shadow {
float: right;
background: #b1b5c4; // gray-blue
width: 200px;
height: 10px;
}

#bottom {
clear: both;
}

#footer {
margin-right: 200px;
background: #444d45; // black
width: 800px;
height: 30px;
}

#aux {
float: right;
background: #444d45; // black
width: 200px;
height: 30px;
}

icio
April 23rd, 2007, 02:15 PM
Give this a try:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>NeoDreamer</title>

<style type="text/css">
body {
margin: 0;
padding: 40px;

font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
#page {
margin: 0 auto 0 auto;
padding: 0;

width: 1000px;
}

/**
* The columns
*/
#col-l {
width: 760px;
}
#col-r {
width: 200px;
float: right;
}

/**
* Specific divs
*/
#main {
margin-bottom: 40px;
background-color: #F00;
}
#stuff {
margin-bottom: 40px;
background-color: #0F0;
}
#user {
margin-bottom: 40px;
background-color: #00F;
}
#aux {
margin-bottom: 40px;
background-color: #FF0;
}
</style>
</head>

<body>
<div id="page">

<div id="col-r">
<div id="user">User Information</div>
<div id="aux">Auxiliary Information?</div>
</div>

<div id="col-l">
<div id="main">The main stuff!</div>
<div id="stuff">More stuff on the left</div>
</div>

</div>
</body>

</html>

Hope it helps :thumb:

biznuge
April 23rd, 2007, 06:03 PM
try removing the doctype from your page. for reasons i don't fully understand in my drunken state, transitional HTML declarations seem to do some fynky things to CSS standards. must be to do with different releases of the standards i guess, but i tried removing it fully and it seemd to hit the LHS of the page as you seem to want.

can't remember which one of the doctype headers works, but i'll post from work tomorrow if i get a chance.:party:

NeoDreamer
April 23rd, 2007, 06:18 PM
Removing the doctype did not change anything for me.

mikkomikko
April 23rd, 2007, 07:15 PM
Your comments are the problem. :smirk:
#nav {
margin-right: 200px;
background: #444d45; /* black */
width: 800px;
height: 45px;
}
CSS doesn't support // -kind of commenting.

NeoDreamer
April 23rd, 2007, 07:27 PM
You're right. Now it works. Shiiiiiiii, son. Man, this is the first time I ever tried CSS layouts...

NeoDreamer
April 23rd, 2007, 07:36 PM
See image for what I'm talking about:

http://img442.imageshack.us/img442/6674/kir4nd9.th.gif (http://img442.imageshack.us/my.php?image=kir4nd9.gif)

How do I change my code so that the 2nd column expands to fit the browser width? I want the 2nd column to still start at X-coordinate: 800px and have a minimum width of 200px, so that if the browser is so tiny, then this column wouldn't disappear.

I also want my main and side DIV's to expand their height as much as they can to fit the browser window, without smashing any other DIV's.

NeoDreamer
April 25th, 2007, 08:41 PM
http://designaxe.com/layout.html

I added width: 100% to #page. In IE, the right column will cut through the left column if the browser width is too small. In Firefox, the right column will smash the left column if the browser width is too small. Additionally, the right column is not filling up all the empty space. When I replace the right column DIV's width to 100%, the left column completely disappears.

This is what I want it to look like:

http://img388.imageshack.us/img388/9255/layouttr7.th.jpg (http://img388.imageshack.us/my.php?image=layouttr7.jpg)

icio
April 26th, 2007, 08:56 AM
Is this what you're trying to achieve:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>NeoDreamer</title>

<style type="text/css">
body {
padding: 40px;
}

#right {
float: right;
width: 200px;
background-color: #0F0;
}
#left {
margin-right: 240px;
background-color: #F00;
}
</style>
</head>

<body>
<div id="right">Content for Right</div>
<div id="left">Content for Left</div>
</body>
</html>

NeoDreamer
April 26th, 2007, 10:17 AM
Where does the "expand to conform to browser" part come in?

NeoDreamer
April 26th, 2007, 05:17 PM
Problem Solved.

I got help from somebody and everything is working now.

icio
April 27th, 2007, 01:41 PM
Post the solution for the reference of others, please.

NeoDreamer
April 27th, 2007, 01:49 PM
http://www.htmlforums.com/css/t-conform-to-the-browser-size-91139.html