I have the following problem: This is the html:
<div>
<a href="x">Link text can also be long</a>
<button class="xx"></button>
</div>
我希望在div中,a和button两个元素始终相邻。
目前情况是,当我改变窗口大小后,如果没有足够的空间容纳这两个元素,button就会被换行,a在第一行,button在第二行。我希望的是,a元素的部分文本也可以和button一起自动换行,这样button永远不会单独出现在第二行。
我该怎么做呢?我已经尝试了white-space:nowrap,但是还没有成功。
编辑:在div上使用display:flex:
我想要的效果:
我不想要的效果: