文本框和按钮对齐

由于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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容