繁体   English   中英

按钮溢出隐藏不起作用

[英]Button overflow hidden not working

我有以下内容:

在此输入图像描述

小提琴链接

HTML:

<button>Here's a long chunk of text</button>

CSS:

button {
   width: 80px;
   overflow: hidden;
}

基本上,我希望按钮不包装文本..

我敢肯定我只是遗漏了一些明显的东西,但我无法弄明白......

添加以下样式以防止换行:

{
    white-space: nowrap;
}

更新小提琴

编辑

现在,既然你试图隐藏溢出,我建议使用text-overflow: ellipsis; 为文本剪切提供更好的外观,最后添加一个(...):

另一个更新的小提琴

 button { width: 80px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } 
 <button>Here's a long chunk of text</button> 

你可以使用white-space: nowrap;

 button { width: 80px; overflow: hidden; white-space: nowrap; } 
 <button>Here's a long chunk of text</button> 

添加white-space:nowrap;

button {
    width: 80px;
    overflow: hidden;
    white-space:nowrap;
}

jsFiddle例子

添加white-space: nowrap; word-wrap: normal;

word-wrap:自动换行属性允许长单词被打破并换行到下一行。

white-space: white-space属性指定如何处理元素内的空白。

 button { width: 80px; overflow: hidden; white-space: nowrap; word-wrap: normal; } 
 <button>Here's a long chunk of text</button> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM