[英]How to make a DIV container that DOES NOT shrink/expand according to its text inside?
basically I want to make a button using a div container.基本上我想使用 div 容器制作一个按钮。 It's a play/pause button, the symbol I use inside the button is bold "ll" for pause and the symbol "►" for play.
这是一个播放/暂停按钮,我在按钮内使用的符号是粗体“ll”表示暂停,符号“►”表示播放。
However when I switch the symbols with javascript inside the button.但是,当我在按钮内使用 javascript 切换符号时。 the width of the div also changes.
div 的宽度也会改变。 As the symbol "►" is a little wider than the bold "ll".
由于符号“►”比粗体“ll”稍宽。
So how can I make the div with a fixed width, so that the "div-box" does not shrink nor expand?那么如何使 div 具有固定宽度,以便“div-box”不会缩小或扩大?
Thanks!谢谢!
Got it fixed, actually display:inline-block;
搞定了,实际上是
display:inline-block;
works but not for all browsers.有效,但不适用于所有浏览器。 I ended up finding a good solution which is to use
<button>
, which by itself is a inline div and you can modify it's dimensions.我最终找到了一个很好的解决方案,即使用
<button>
,它本身就是一个内联 div,您可以修改它的尺寸。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.