简体   繁体   中英

Aligning DIVs using float property

How would I align divs like the following (example content below the divs)...I set float to left for both div1 and div2 but then div3 floated to the top right, how do I prevent this?

<div1>                <div2>
What is the temp.?    ____________________
Is it raining?        ____________________

<!-- Contains main content -->
<div3>

You need to set a clear fix to place after the floated divs. This is what I do.

Make this class in your stylesheet:

.clear {clear:both}

The after your two floated divs, right before <div3> include this html:

<div class="clear"></div>

This should keep your 3rd div below the floated divs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM