Do not use on any
shared computer
August 29, 2008 08:11pm pdt
 
[x]
Attachment Details

Float / Clear / Div / Alignment

Tags: css html, float clear css html
Hi -
I can get the code to work most of the time inline, but not with css. How can I make the attached divs float to the left and the right, as displayed, but align to the top? If they align to the top, I assume then the divs would look to be on the same line. I have tried floats and clears, but just can not get it to work.
Thanks,
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
<!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>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Home | About Us | Sign Up | Tour</title>
<style type="text/css">
.navigation {
	width: 750px;
	margin:0px;
	height:75px;
	background-color:aqua;
	
}
 
.navigation.search {
	margin:0px;
	float:right;
	width:auto;
 
}
 
</style>
</head>
 
<body>
 
	<div class="navigation">Home | About Us | Sign Up | Tour | Help
	<div class="navigation search">
			<!-- Search Google Start -->
			<center>
			<form method="get" action="http://www.google.com/custom" target="google_window">
			<a href="http://www.google.com/">
			<img src="http://www.google.com/logos/Logo_25wht.gif" border="0" alt="Google"></img></a>
			<label for="sbi" style="display: none">Enter your search terms</label>
			<input type="text" name="q" size="31" maxlength="255" value="" id="sbi"></input>
			<label for="sbb" style="display: none">Submit search form</label>
			<input type="submit" name="sa" value="Search" id="sbb"></input>
			<input type="hidden" name="client" value="pub-9923779901903876"></input>
			<input type="hidden" name="forid" value="1"></input>
			<input type="hidden" name="channel" value="1981285639"></input>
			<input type="hidden" name="ie" value="ISO-8859-1"></input>
			<input type="hidden" name="oe" value="ISO-8859-1"></input>
			<input type="hidden" name="cof" value="GALT:#008000;GL:1;DIV:#336699;VLC:663399;AH:center;BGC:FFFFFF;LBGC:336699;ALC:0000FF;LC:0000FF;T:000000;GFNT:0000FF;GIMP:0000FF;FORID:1"></input>
			<input type="hidden" name="hl" value="en"></input>
			</form>
			</center>
			<!-- Search Google End -->
 
	
	</div></div>
	
</body>
 
</html>
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Web Development
Question Asked By: prtllc
Solution Provided By: landship
Participating Experts: 2
Solution Grade: A
Views: 151
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by zemond

Rank: Master

Expert Comment by zemond:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by prtllc
Author Comment by prtllc:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by landship
Accepted Solution by landship:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Open Discussion
Open Discussion
 
Comment by prtllc
Thanks.
 
 
Comment by zemond
You do not need to specify the width, you can archeive the full width of an undenfined area by using margins
 
 
Comment by landship
It is best practice to always specify the width of a floated element, how do you achieve full width using margins?

I've used padding before, but that requires hacks in IE 5 and complicates things.
 
 
Comment by zemond
gday landship ill dig up my old code, and send it on through

 
 
Comment by zemond
Gday Landship, i wont go into too much detail you are an expert should be able to figure out urself

here is the page

http://sapcookbook.com

the center box is a floated div that scales,

here is the theory

the width of the block element (div) is set to 100%; and in my example, i have 2 blocks either side, with a set width, if for example the width is 200, then position expandable div and margin-left:200px;

Its slightly more complicated then that, but works the treat, FF, IE, Safari, and a few others i tested,

The code may be slightly dirty, it is an old site
 
 
Comment by landship
I think you may have sent the wrong link, all 3 columns scale since they are floated left and have their width set as percentages.
 
 
Comment by zemond
Ahh dang your right, Ill find the actual one, If i cannot, ill write up the script for you.
 
 
Comment by landship
ok, I see now, with position absolute for the left column. Thanks for the follow-up zemond.

I originally thought you meant a way with margins, floats and relative positions so I was curious to see how you worked it out, but this makes sense.
 
 
Comment by zemond
Hmm its been a while since i wrote that, I am using margins arnt I? with floated divs

Ahh well I know it works, its div's not tables, and is cross browser. All is well.
 
 
Comment by landship
All is well, and it was using margins.
 
 
20080723-EE-VQP-34 / EE_QW_2_20070628