html - CSS 自动换行不适用于 <a> 标签

标签 html css word-wrap

我正在为标签:a 使用 Word-wrap:brakword。如果它溢出 width:100px;

tag:a 的样子:

enter image description here

tag:a 应该如何:

enter image description here

我的代码如下所示:

div{
    width: 50px;
}
.GreenBtn {
    background-color: #6aae12;
    border: 1px solid #539102 !important;
    color: #FFFFFF !important;
    cursor: pointer !important;
}
.buttonGreen {
    font-family: 'Roboto';
    border: 1px #ddd solid;
    background: #6AAE12;
    color: #FFF;
    /* margin-bottom: 10px; */
    padding: 7px 12px;
    transition: color 300ms ease-in-out 0s, background-color 300ms ease-in-out 0s, background-position 300ms ease-in-out 0s;
}
<div >
  <a class="GreenBtn buttonGreen" style="text-decoration: none;" href="#">
    <span> Bestellung anzeigen </span>
  </a>
</div>

最佳答案

作为Vitorino fernandes在评论中告知,在 .GreenBtn 中添加了 display:block。 它按预期工作。

.GreenBtn {
        background-color: #6aae12;
        border: 1px solid #539102 !important;
        display:block
        color: #FFFFFF !important;
        cursor: pointer !important;
    }

关于html - CSS 自动换行不适用于 <a> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33607513/

相关文章:

jQuery 标签问题

css - 图像固定在中心的框内

css - float 元素需要在 table-cell li 中居中

html - 在移动 View 中强制 Google AdSense 单元的边距

javascript - 文件读取器在 Chrome 中不工作

javascript - 图像尺寸奇怪

javascript - 在元素中查找未包裹在 html 标签中的文本,并用 <p> 包裹它

html - 左右浮动两个div : How can I keep them on the same level when a page resizes?

c# - 根据TextWrapping 属性获取TextBlock 的行数?

html - 两个 div : height auto and 100%