Columns property not aligning correctly
I am trying to create a three column layout for my website. When I use the column property and set it to "3" columns, it doesn't align correctly. Each column after the previous seems to be pushed down a little bit more. Is there a way to correct this? It does the same thing when I set the column count to "5" column and minimize the window
.widget-column {
columns: 5em 3;
/* Test with 5 columns */
-moz-columns: 5em 3;
/* Test with 5 columns */
-webkit-columns: 5em 3;
/* Test with 5 columns */
}
.widget-column p {
padding: 1em;
}
<div class="widget-column">
<p>Column</p>
<p>Column</p>
<p>Column</p>
<p>Column</p>
<p>Column</p>
</div>
Since <p>
is a block level element, it adds a newline both before and after the element. But, you can make it as inline-block level, by setting display:inline-block;
plus width:100%;
for expanding the width.
* {
margin: 0;
padding: 0;
}
.widget-column {
margin: 10px;
text-align: center;
columns: 5em 3;
-o-columns: 5em 3;
-ms-columns: 5em 3;
-moz-columns: 5em 3;
-webkit-columns: 5em 3;
column-gap: 0px;
-o-column-gap: 0px;
-ms-column-gap: 0px;
-moz-column-gap: 0px;
-webkit-column-gap: 0px;
}
.widget-column p {
background: #EEE;
padding: 1em;
display: inline-block;
width: 100%;
}
<div class="widget-column">
<p>Column</p>
<p>Column</p>
<p>Column</p>
<p>Column</p>
<p>Column</p>
</div>
You have to use <span> in case of <p> tag, <p> tag by default starts from next line
Here is the plnk:
http://plnkr.co/edit/n4TlD6nVSqOa9U5F2PON?p=preview
链接地址: http://www.djcxy.com/p/86242.html上一篇: flask admin自定义QueryAjaxModelLoader
下一篇: 列属性未正确对齐