[英]CSS DIV wrapping line height
I'm setting up a grid of DIV's which I want displayed inline. 我正在设置一个DIV的网格,我希望以嵌入式方式显示它。 The DIVs contain and image + text of variable, and ideally the DIVs themselves should be constrained to a fixed width.
DIV包含变量的图像和文本,理想情况下,DIV本身应限制为固定宽度。
.playerbox {
width: 100px;
border: 1px solid;
float: left;
margin: 10px;
}
I'm finding that on DIVs where the text wraps, the grid does not display inline as expected - the order of the next row(s) is affected. 我发现在文本换行的DIV上,网格未按预期显示内联-下一行的顺序受到影响。
Example here: http://jsfiddle.net/qC72A/ 此处的示例: http : //jsfiddle.net/qC72A/
Presume I need to set a line height or similar, but not sure of the best way to handle this. 假设我需要设置线条高度或类似高度,但是不确定要处理的最佳方式。
Set a static height for each .playerbox 为每个.playerbox设置一个静态高度
.playerbox { height:200px; }
Forked example at http://jsfiddle.net/avbXD/ http://jsfiddle.net/avbXD/上的分支示例
Remove the float
from .playerbox
and set it to inline-block
instead. 从
.playerbox
移除float
.playerbox
然后将其设置为inline-block
。 Then you can set vertical-align
to top, middle, or bottom depending on how you want them to align. 然后,您可以根据希望它们的对齐方式将“
vertical-align
设置为顶部,中间或底部。
http://jsfiddle.net/qC72A/9/ http://jsfiddle.net/qC72A/9/
I think you need to use column-count
and also need to wrap the playerboxes with div <div id="container" class="cols">
Check this Fiddle http://jsfiddle.net/qC72A/11/ 我认为您需要使用
column-count
,还需要用div包装播放器框<div id="container" class="cols">
检查此小提琴http://jsfiddle.net/qC72A/11/11
HTML HTML
<div id="container" class="cols">
<div class="playerbox"><a href="index.php?act=update&id=1"><img class="greyscale" src="img/00068200_Image.jpg"><p>Maurice Blair</p></a></div>
</div>
CSS CSS
#container {
width: 100%;
margin: 20px auto;
}
.cols {
-moz-column-count:5;
-moz-column-gap: 3%;
-moz-column-width: 18%;
-webkit-column-count:5;
-webkit-column-gap: 3%;
-webkit-column-width: 18%;
column-count: 5;
column-gap: 3%;
column-width: 18%;
}
.playerbox {
border: 1px solid;
margin-bottom: 10px;
}
.playerbox img {
width: 100px;
height: 100px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.