美文网首页
文本框和按钮对齐

文本框和按钮对齐

作者: 没人能救你呀吼 | 来源:发表于2017-04-09 21:05 被阅读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

    相关文章

      网友评论

          本文标题:文本框和按钮对齐

          本文链接:https://www.haomeiwen.com/subject/zunhattx.html