我在一个position:absolute
容器div中有一个div relative
。 absolute
位置div
的宽度是一个百分比,当我减小浏览器大小从而缩小div
的大小时,li
文本将被截断,我将包括屏幕截图。我希望li
中的文本可以换行而不写<br>
,因为它们将动态生成。好的,这是我的代码
// HTML
<div class="information-toggle">
<aside class="information-toggle__list">
<ul>
<li>Meaningless Existence</li>
<li>Meaningless Existence</li>
<li>Meaningless Existence</li>
<li>Meaningless Existence</li>
</ul>
</aside>
<div class="information-toggle__content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div>
</div>
// SASS
.information-toggle{
// border:1px solid red;
position:relative;
margin:0 auto;
font-family: 'Avenir',sans-serif;
}
.information-toggle__list{
width:100%;
// border:1px dashed green;
z-index: 100;
position:relative;
@media only screen and (min-width: 768px) {
position:absolute;
width:25%;
}
ul{
list-style-type: none;
padding: 0;
text-align: center;
overflow-x:scroll;
white-space: nowrap;
@media only screen and (min-width: 768px) {
display:list-item;
overflow-x:initial;
}
li{
background: $button-red;
border-bottom: 2px solid #ffffff;
font-weight: 500;
@include font-size(2.0);
letter-spacing: 0.08px;
position: relative;
height: 46px;
line-height: 46px;
display: inline-block;
color: $white;
margin: 5px;
border-radius:5px;
@media only screen and (min-width: 768px) {
display:list-item;
border-radius:initial;
border-top-left-radius:5px;
border-bottom-left-radius:5px;
margin:initial;
height: 67px;
line-height: 67px;
}
&:hover {
background:$button-red-hover;
@media only screen and (min-width: 768px) {
@include rightArrow();
font-weight:900;
}
}
}
}
}
.information-toggle__content{
width: 100%;
// border: 1px dashed orange;
margin-left: auto;
padding: 25px;
background: $white;
//transform: translateY(33px);
@media only screen and (min-width: 768px) {
padding: 50px;
width: 75%;
transform: translateY(33px);
}
}
答案 0 :(得分:2)
答案 1 :(得分:0)
在li
项目上放whitespace: normal
,height: auto
和min-height: 67px
答案 2 :(得分:0)
您可以将overflow-wrap: break-word;
应用于父级div。