/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] floating boxes in a liquid layout

Hi Guys, I’m trying to float 3 boxes which are fixed withs across the page but have them distibuted evenly (so that the space around them shrinks when the browser is smaller not the boxes).

I can get them to go across and behave as I want them to, but I cannot get the clearing to work so that they all sit on the same line.

Can anyone help??

I have put the code for this below, as you will see “box 3” is sitting lower than box 1 and box 2 and I want them all on the same line.

[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 type=”text/css”>
#box1
{
border:2px solid #006633;
width: 100px;
float:left;
}
#box2
{
border:2px solid #000000;
width: 100px;
float:none;
margin:auto;
}
#box3
{
border:2px solid #CCCC33;
width: 100px;
float: right;
}
</style>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>

<body>
<div id=”box1″>
<p>This is box 1 </p>
</div>

<div id=”box2″>
<p>This is box 2 </p>
</div>

<div id=”box3″>
<p>This is box 3 </p>
</div>

</body>
</html>[/CODE]

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@CoyotelabAug 24.2008 — &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;style type="text/css"&gt;
#mainbox
{
width:320px;
float:left;
height:100px;
}
#box1
{
border:2px solid #006633;
width: 100px;
float:left;
margin-right:1px;
}
#box2
{
border:2px solid #000000;
width: 100px;
float:left;
margin-right:1px;
}
#box3
{
border:2px solid #CCCC33;
width: 100px;
float: left;
}
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div id="mainbox"&gt;
&lt;div id="box1"&gt;
&lt;p&gt;This is box 1 &lt;/p&gt;
&lt;/div&gt;

&lt;div id="box2"&gt;
&lt;p&gt;This is box 2 &lt;/p&gt;
&lt;/div&gt;

&lt;div id="box3"&gt; <br/>
&lt;p&gt;This is box 3 &lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@CentauriAug 25.2008 — The floated boxes (1 & 3) should come [B]before[/B] the unfloated box (2) in the html.
Copy linkTweet thisAlerts:
@snowy-14authorAug 25.2008 — Brilliant, as easy as that! I had tried them in 3 - 2 - 1 order which just reversed the problem. It seems obvious now!

Thanks very much cor your help.
×

Success!

Help @snowy-14 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...