我已经创建了一个div使用显示网格有列结构。
<div id="two-column-structure">
<div></div>
<div></div>
</div>
样式使用CSS
div.two-column-structure {
display: grid;
grid-template-columns: 1fr 380px;
}
但是当我在第一列写一些大词,比如asdjlkasjdlkjsalkdjalskjdlkajsdlakjsdlkajsdlkasjdlkasjdlasjdlkfahskldhfalksdjhflakjsdhflaksjdhflkasaklsjdhfaklsdhflaksdhflkajsdhlafkjdshflkajfsdhlfkajshdlkfajhsdlfjashdlkfjashdlkjahskldsfjhalskdjf
布局有溢出-x和我的设计得到网状。
我知道谁会这么做,但我认为这可能是案件。
.two-column {
display: grid;
grid-template-columns: 1fr 380px;
padding: 12px;
border: 1px solid red;
margin-bottom: 10px;
}
.two-column div {
padding: 10px;
}
.two-column-i-tried {
display: grid;
grid-template-columns: 1fr 380px;
padding: 12px;
border: 1px solid green;
margin-bottom: 10px;
}
.two-column-i-tried div:first-child {
border: 1px solid blue;
text-overflow: ellipse;
overflow: hidden;
}
<div class="two-column">
<div> slkdjflksdjfksajd;lkfaj;sldkjfa;lskdjflaksdkjghakljdfshgksldjfhgklsjdfhlgksjdfhgklsjdhflkgsjdhflkgsjhldfkjghskldjfhgskljdfhgksldhfgklsjdfhgklsjdhfgkjlshdfg
</div>
<div>
Right Column
</div>
</div>
<div class="two-column">
<div>
Without long words it works fine but if there is no space in between it gets overflowed. What can I do for the same. I have used max-width, min-width, text-overflow and overflow which can be showed in two-column-i-tried class div
</div>
<div>
Right Column
</div>
</div>
<div class="two-column-i-tried">
<div> slkdjflksdjfksajd;lkfaj;sldkjfa;lskdjflaksdkjghakljdfshgksldjfhgklsjdfhlgksjdfhgklsjdhflkgsjdhflkgsjhldfkjghskldjfhgskljdfhgksldhfgklsjdfhgklsjdhfgkjlshdfg
</div>
<div>
Right Column
</div>
</div>
<div class="two-column-i-tried">
<div>
Without long words it works fine but if there is no space in between it gets overflowed. What can I do for the same. I have used max-width, min-width, text-overflow and overflow which can be showed in two-column-i-tried class div
</div>
<div>
Right Column
</div>
</div>
在html代码段中,当我使用text-overflow和overflow处理长文本时,它不显示代码中所示的省略号
3条答案
按热度按时间ujv3wf0j1#
试试这个:
CSS的word-break属性用于设置文本是否在内容框溢出的地方出现换行符。
更多关于财产的信息:https://developer.mozilla.org/en-US/docs/Web/CSS/word-break
wlp8pajw2#
TheWorrier,试试这个,我们可以用text-overflow:“..."
.two-column-i-tried div:first-child {
边框:1 px纯蓝色;
溢出:隐藏;
文本溢出:“...";
}
wgx48brx3#
试试.**grid-template-columns:repeat(3,1fr);**repeat(3,1fr)是创建3个等宽列。