首页 > 解决方案 > 这段代码可以减少并且仍然具有相同的效果吗?

问题描述

下面的任何代码都是不必要的吗?我认为我在这里有超出要求或未遵循最佳实践的内容。

#button {
    color: #fff !important;
    text-transform: uppercase;
    text-decoration: none;
    background: #grey;
    padding: 1%;
    border-radius: 6px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 350px;
    text-align: center;
    font-weight: bold;
    font-size: 20px;
    font-family: Avenir;
    cursor: pointer;
    border: none;
    transition: all 0.4s ease 0s;
    z-index: 5;
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
}


标签: cssbutton

解决方案


是的,如果使用它可能会更紧凑

margin: 0 auto;

推荐阅读