以下是我的HTML代码:
<div class="progress">
<div class="progress-bar progress-bar-warning progress-bar-striped first-bar" style="width:10%;">I want this text to overflow into the div to the right</div>
<div class="progress-bar progress-bar-success second-bar" style="width:90%;">I want this text to overflow into the div to the left</div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-warning progress-bar-striped first-bar" style="width:90%;">I want this text to overflow into the div to the right</div>
<div class="progress-bar progress-bar-success second-bar" style="width:10%;">I want this text to overflow into the div to the left</div>
</div>
这是我的CSS代码:
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
.first-bar {
white-space: nowrap;
position: relative;
text-align: left;
}
.second-bar {
white-space: nowrap;
text-align: right;
direction: rtl;
}
我想要在每个
progress
类的 div 中溢出所有 div 元素的文本。您可以在这里查看我的 Fiddle,了解我试图做什么以及我的 CSS 如何将左侧 div 的文本溢出到右侧 div,但不能反过来(即右侧 div 的文本溢出到左侧 div)。如何让它反过来工作?我尝试在 second-bar
的 CSS 中添加 position: relative;
,但这对我不起作用,因为它会破坏第一种情况。