文本框和按钮对齐

2017-04-09  本文已影响102人  没人能救你呀吼

由于input和button都是行内块级元素所以有间隙。浮动后变为块级元素间隙消失。
也可以flexbox布局更方便。

<div class="search_bar">
            <input type="text">
            <button>搜索</button>
</div>
.search {
    width: 400px;
    height: 38px;
    border: solid 1px #441605;
}
        
input, button {
    float: left;
    outline: none;
    height: 38px;
    border: 0;
    padding: 0;
    line-height: 38px;
}

input {
    width: 80%;
    font-size: 16px;
    text-indent: 16px;
}

button {
    width: 20%;
    color: #fff;
    font-size: 20px;
    text-align: center;
    background: #a24729;
    cursor: pointer;
}

效果:

未标题-1.png
上一篇 下一篇

猜你喜欢

热点阅读