我有两个按钮,一个在屏幕左边,一个在屏幕右边,希望在屏幕缩小的时候它们能够很好地折叠。视觉上,我想要的效果是这样的:
________________________________________________________________
| |
| |LongTextButtonName| |LongTextButtonName| | When the screen
|_______________________________________________________________| is large
_______________________________________
| |
| |LongTextBu...| |LongTextBu...| | When the screen is small
|______________________________________|
很不幸,现在我得到了这个:
________________________________________
| |
| |LongTextButtonName| |
| |LongTextButtonName| |
|_______________________________________|
我希望使用纯CSS的解决方案。
这是我当前的HTML和CSS(这里有一个演示):
<div class="button-container">
<div class="left-button"><a>LongTextButtonName</a></div>
<div class="right-button"><a>LongTextButtonName</a></div>
</div>
.button-container {
min-width:320px;
}
.button-container > div {
border: 1px solid gray;
background-color: orange;
min-width: 160px;
padding: 8px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.left-button {
float: left;
}
.right-button {
float: right;
}
box-sizing: border-box
是什么作用? - Nick G.