![](/img/trans.png)
[英]jQuery + CSS - where 4th div is coming under 3rd div, wrap 3 div in one line, and 4th - on next line
[英]Create thee divs in one line and 4th div in bottom. CSS/HTML
我想创建下一个愿景的html页面。 div 1,2和3在一行中的位置已经完成,但是对于第4个div我有一些麻烦并且无法实现。
你真的应该发布你的代码,看看它有什么问题。但我为你做了一个例子。
你去,你可以使用浮动。
Html代码:
<div id="wrapper">
<div id="first">
</div>
<div id="second">
</div>
<div id="third">
</div>
<div id="fourth">
</div>
</div>
Css代码:
#wrapper{width:300px; margin:0;}
#first { height:300px; width:100px; background:black; float:left;}
#second{ height:250px; width:100px; background:red;float:left;}
#third{ height:250px; width:100px; background:green;float:left;}
#fourth{ height:50px; width:200px; background:blue;float:left;}
工作演示
这是一个使用非固定高度和宽度的示例。 关键是将子部分包装在divs
中并相应地进行样式化。 div
毕竟是分裂的缩写。
<div class="left">
1
</div>
<div class="right">
<div class="second-third-wrapper">
<div class="second">
2
</div>
<div class="third">
3
</div>
</div>
<div class="fourth">
4
</div>
</div>
然后divs
使用百分比高度和宽度来正确调整它们的大小。 这些百分比占父元素的一定百分比( <body>
,然后继承自<html>
),因此父元素高度也需要设置。
body, html {
width: 100%;
height: 100%;
}
.left {
background-color: blue;
width: 50%;
height: 100%;
float: left;
}
如果您希望它们具有固定的大小,您可以在特定元素上设置特定的height
和width
样式,剩下的百分比将完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.