我有一个固定宽度的按钮。在这个按钮中有一个 <b>
带有名称的标签。
名称是可变的,它可以长于按钮的宽度。
在浏览器中查看时,较长的文本不适合按钮。 有没有办法对按钮文本进行连字?文本没有“空格”但有下划线:“_”。
最佳答案
我猜你想要一个长文本出现在有限宽度的按钮中。看看 DEMO 首先。
CSS
#test{
display: block;
width:100px;
height:30px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-break: break-all;
word-wrap: break-word;
}
HTML
<button type="button" id="test">text_hyphenation_within_a_html_button</button>
关于html - html按钮内的文本连字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24488626/