I am trying to use css3 columns with a list (<li>).
I am having trouble making it work.
I defined a div that wraps the <ul>
div.ul-container {
-moz-column-width: 310px;
-moz-column-gap: 10px;
-webkit-column-width: 310px;
-webkit-column-gap: 10px;
column-width: 310px;
column-gap: 10px;
}
This works fine when I have three <li>s or above. But when I have less than that (2 or 1) it seems to cut off the <li>. I tried defining a min-height which didn't work as well (it treated it as height).
screenshot:
any ideas?
This thread is a bit old, but I had the same issue recently and used this to prevent the list items from getting cut:
li {
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
}
More info on CSS-Tricks
Hope it helps anyone in the same boat!
It seems to be linked to margins on li elements and ol.
From jsfiddle.net/nZUB9 I reseted your CSS at first and then turn margin: 6px 0; into padding: 6px 0;
It did the job for me ;)
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
* {
margin: 0;
padding: 0;
font-family: arial, verdana;
}
.task-wrapper {
-moz-column-width: 310px;
-moz-column-gap: 10px;
-webkit-column-width: 310px;
-webkit-column-gap: 10px;
column-width: 310px;
column-gap: 10px;
border:1px solid red;
}
ol.tasks {
list-style-type: none;
margin-left: 0;
display: block;
}
ol.tasks li {
border-bottom: 1px dotted rgba(0, 30, 30, 0.3);
background-color: white;
background-color: rgba(255, 255, 255, 0.9);
}
ol.tasks li {
border: 1px solid rgba(0, 30, 30, 0.3);
padding: 6px 0;
list-style-type: decimal;
width: 310px;
}
来源:https://stackoverflow.com/questions/11921852/css3-columns-cutting-off-lis