Home > Web Front-end > HTML Tutorial > Wrong div position_html/css_WEB-ITnose

Wrong div position_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:16:29
Original
1311 people have browsed it

My original intention was to have the top two side by side, and the third one at the bottom


left part 🎜>


div.main-body{
width:900px;
height:900px;
background:#000;
margin:0px auto;
padding:0;
}

div.left{
width:600px;
height:600px;
background:#00F;
float:left;
margin-left:0px;
}

When displayed, the first one is always some distance away from the left, so that the second one cannot be placed, and then it is displayed below.


Reply to discussion (solution)


The blue part is left, and the black part is main-body. Shouldn't blue be on the left? ? ? ? ?

Why don’t you use a table to control the layout? The div is embedded in the table

<!DOCTYPE html><html><head><style>* {margin:0px;padding:0px}#page {width:900px;background:#ccc;margin:100px auto;}#left {width:450px;height:50px;background:blue;float:left;}#right {width:450px;height:50px;background:red;float:left;}#down {width:900px;background:green;height:50px;float:left;}</style></head><body><div id="page"><div id="left">left</div><div id="right">right</div><div id="down">down</div></div></body></html>
Copy after login

The first step is to reset the css

div.main-body{width:900px;height:900px;background:#6F9;margin:0px auto;padding:0;}div.left{width:600px;height:600px;background:#00F;float:left;margin-left:0px;}div.right{width:300px;height:600px;background:red;float:left;margin-left:0px;}
Copy after login

When encountering layout and position problems, it is recommended to unify absolute and finally include a relative. This is the easiest and most intuitive. Just use top, left, right, bottom: .

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template