I have this list in HTML and I would like order it by columns. I tried using floats it gives me this:
EDIT :
Height of these <li>
is undefined, but I would like C below B, E below E and G below F without change the structure and change the order. I don't want to use position absolute. I'm wondering if there are other solutions.
HTML :
<ul>
<li class="item">A</li>
<li class="item">B</li>
<li class="item">C</li>
<li class="item">D</li>
<li class="item">E</li>
<li class="item">F</li>
<li class="item">G</li>
<ul>
OUTPUT (using float: left; width: 240px; border-left: 1px solid #EEE
) :
What I want is more like this below, without changing the HTML because I already use this structure to make responsive.
Is it possible ?
And then, we can use this class name inside DIV class attribute, to float to the right end. CSS contains clear property, to cancel the applied float property to prevent its effect on the DIV containers to be displayed to the browser with new line. This property is mainly used when we are required to display content in grid view using DIV tags.
Inherits this property from its parent element. Read about inherit Let the first letter of a paragraph float to the left and style the letter: Use float to create a homepage with a header, footer, left content and main content: Do not allow floating elements on the left or the right side of a specified <p> element:
The float property can have one of the following values: left - The element floats to the left of its container. right - The element floats to the right of its container. none - The element does not float (will be displayed just where it occurs in the text). This is default.
A way to solve the problem is forcing some in-flow element to be placed below all floats. Then, the height of the parent will grow to wrap that element (and thus the floats too). This property indicates which sides of an element's box (es) may not be adjacent to an earlier floating box.
You could use column CSS and a margin-bottom on the first LI tag, like this.
ul {
column-count:4;
padding:0;
column-rule: solid lightgray 1px;
}
li {
display:inline-block;
width:100%;
}
li:before {/* demo purpose to set an height to lis */
content:'';
float:left;
padding-top:50%;
}
li:first-of-type {
margin-bottom:50%;
}
You may need a JavaScript prefixer or add vendor-prefix manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With