我试图获取一个可滚动的标签列表,这些标签显示在两列中。
display: inline
应该有用,但似乎并非如此。我对此有一个适度的尝试:http://jsfiddle.net/pdExf/860/,但它缺少我上面要求的要求。
HTML :
<div>
<ul>
<li>
<label>
<input type="checkbox"/>
<span> 1-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 2-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 3-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 4-very_short_word </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 5-medium_length_word </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 6-still_no_spaces </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 7-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
</label>
</li>
</ul>
</div>
CSS:
span {
margin-left: 14px;
flex: 1 1 auto;
overflow: 'hidden',
word-wrap: break-word;
}
label {
box-sizing: border-box;
background: white;
color: black;
padding: 10px;
margin: 10px 10px 20px 10px;
display: flex;
border: 1px solid black;
}
ul {
display: flex,
flex: 1 1 auto;
flex-wrap: wrap;
margin: 10px 0px 0px 10px;
column-count: 2;
column-gap: 20px;
}
div {
height: 130px;
background-color: lightblue;
overflow: scroll;
}
li {
display: inline; // want labels to display left-to-right
}
还应该添加什么才能使其发挥作用?
答案 0 :(得分:0)
使用word-wrap: break-word;
&amp; word-break:break-all;再添加一个; &amp; white-space: normal;
<强> Revised Fiddle 强>
label span {
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -webkit-pre-wrap; /*Chrome & Safari */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: pre-wrap; /* css-3 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
word-break: break-all;
white-space: normal;
}
span {
margin-left: 14px;
flex: 1 1 auto;
overflow: 'hidden', word-wrap: break-word;
}
label span {
white-space: -moz-pre-wrap !important;
/* Mozilla, since 1999 */
white-space: -webkit-pre-wrap;
/*Chrome & Safari */
white-space: -pre-wrap;
/* Opera 4-6 */
white-space: -o-pre-wrap;
/* Opera 7 */
white-space: pre-wrap;
/* css-3 */
word-wrap: break-word;
/* Internet Explorer 5.5+ */
word-break: break-all;
white-space: normal;
}
label {
box-sizing: border-box;
background: white;
color: black;
padding: 10px;
margin: 10px 10px 20px 10px;
display: flex;
border: 1px solid black;
}
ul {
display: flex, flex: 1 1 auto;
flex-wrap: wrap;
margin: 10px 0px 0px 10px;
column-count: 2;
column-gap: 20px;
}
div {
height: 130px;
background-color: lightblue;
overflow: scroll;
}
li {
display: inline; // want labels to display left-to-right
}
<div>
<ul>
<li>
<label>
<input type="checkbox"/>
<span> 1-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 2-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 3-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 4-very_short_word </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 5-medium_length_word </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 6-still_no_spaces </span>
</label>
</li>
<li>
<label>
<input type="checkbox"/>
<span> 7-thisisaverrrrrrrrrrrrryyyyyy_long_word_with_no_spaces </span>
</label>
</li>
</ul>
</div>