我有两个按钮浮动到屏幕的相对两侧,如果屏幕缩小,我希望它们能很好地折叠。从视觉上看,这就是我想要的:
________________________________________________________________
| |
| |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;
}