/    Sign up×
Community /Pin to ProfileBookmark

I have been trying without luck to fit two divs side by side inside another. The right one keeps falling below the left one though not directly. I can’t figure out what I have done wrong, but certainly nothing is OK. Anyone out there ?

<div>
<leftdiv>
<div>
<rightdiv>
</div>
</div>

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@ray326Oct 08.2007 — <div style="width:30%;float:left">first div</div>

<div style="width:30%;float:left">next div</div>

I.e. width and float is the key.
Copy linkTweet thisAlerts:
@bingecoderauthorOct 08.2007 — I want to size by actual width. Total width is 1000. Left box is 200 and right is 780 .
Copy linkTweet thisAlerts:
@tgormtxOct 08.2007 — [CODE]<div style="width:1000px;">
<div style="float:left;width:200px;">Left Div Tag</div>
<div style="float:left;width:780px;">Right Div Tag</div>
</div>[/CODE]



Ray is right: Float and width are key. You might also need to check out browser compatibility. Do a Google search on the Box Model Hack if you start having issues with cross browser issues.
Copy linkTweet thisAlerts:
@bingecoderauthorOct 08.2007 — Thanks , it is sorted . I missed out one div and that was the problem
×

Success!

Help @bingecoder 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.18,
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,
)...