Bootstrap - 为什么我的按钮没有响应?

时间:2017-08-06 12:56:26

标签: css twitter-bootstrap

正如您在下面的屏幕截图中看到的,我的粉红色按钮没有完全响应:低于某个宽度,它会被剪切而不是调整大小以保持在视口宽度内。 有什么问题? 非常感谢

enter image description here

.btn {
    background-color: #ff00bf;
    border: 0 none;
    border-radius: 25px;
    box-shadow: 0 11px 22px rgba(34, 34, 34, 0.2);
    color: #fff;
    display: inline-block;
    font-size: 1rem;
    letter-spacing: 0.025em;
    padding: 1.1em 2.28em 1em;
    text-decoration: none;
    transition: all 0.3s ease-out 0s;
}
.btn {
    -moz-user-select: none;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: inline-block;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.42857;
    margin-bottom: 0;
    padding: 6px 12px;
    text-align: center;
    touch-action: manipulation;
    vertical-align: middle;
    white-space: nowrap;
}

1 个答案:

答案 0 :(得分:2)

白色空间:nowrap使得破线不可能。只需删除它。我也会将max-width设置为100%。

.btn {
    background-color: #ff00bf;
    border: 0 none;
    border-radius: 25px;
    box-shadow: 0 11px 22px rgba(34, 34, 34, 0.2);
    color: #fff;
    display: inline-block;
    font-size: 1rem;
    letter-spacing: 0.025em;
    padding: 1.1em 2.28em 1em;
    text-decoration: none;
    transition: all 0.3s ease-out 0s;
}
.btn {
    -moz-user-select: none;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: inline-block;
    font-size: 14px;
    font-weight: normal;
    line-height: 1.42857;
    margin-bottom: 0;
    padding: 6px 12px;
    text-align: center;
    touch-action: manipulation;
    vertical-align: middle;
    max-width: 100%;
}