这是一个很难用语言表达的问题,所以我认为需要进行实际演示。
我有一组 html 元素:
<div class="outer-div"> // Container
<div class="content-div"></div> // Text goes into this element
<span class="clear-button"></span> // BG image for this is a 16x16 icon
<span class="select-button"></span> // BG image for this is a 16x16 icon
</div>
哪个使用这个css:
div.select-div {
background-color: white;
border: 1px solid #CCC;
vertical-align: middle;
margin-bottom: 10px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
height: 20px;
padding: 4px 6px;
}
div.content-div {
float: left;
overflow: hidden;
background-color: white;
vertical-align: middle;
font-size: 14px;
color: #555;
height: 20px;
width: auto;
}
span.select-button {
cursor: pointer;
display: inline-block;
float: right;
width: 16px;
height: 16px;
margin-top: 2px;
position: relative;
background-color: red; // for testing simplicity, this would be a bg image
}
span.clear-button {
cursor: pointer;
display: inline-block;
float: right;
width: 16px;
height: 16px;
margin-top: 2px;
position: relative;
background-color: black; // for testing simplicity, this would be a bg image
}
文本被添加到内容 div 中,并且适用于少量文本,例如:
但是,如果您添加更多文本,则会发生这种情况:
我一直在努力寻找一种方法来阻止这些图标从它们的位置移动,但我无法解决。理想情况下,我希望 div 垂直扩展,但是隐藏溢出文本也可以。外部 div 宽度可能会有所不同。