我添加了文档类型标签并更改了按钮的高度


<div class="searchbox">
    <form>
        <input type="text" name="src-txt" class="src-txt"/>
        <input type="submit" value="" name="src-btn" class="src-btn"/>
    </form>
</div>

.searchbox {
    float: left;
    width: 35%;
    height: 30px;
    margin-top: 25px;
    margin-left: 3%;
    border: 1px solid red;
}
.src-txt {
    float: left;
    width: 80%;
    height: 100%;
    border: 2px solid #3682c4;
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
    padding: 5px;
}
.src-btn {
    float: left;
    width: 15%;
    height: 100%;
    background-color: #3682c4;
    background-image: url("../content/src_img.png");
    background-repeat: no-repeat;
    background-position: center;
    border: none;
    cursor: pointer;
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

这是代码,它工作正常,但是在我添加之后!头部搜索按钮高度的 DOCTYPE html 降低了。

我不明白发生了什么变化。

原因是什么?

我应该对代码进行哪些更改?

你不能在

添加 !DOCTYPE html?您的 html 标记是否设置为 100% 高度?有时这会导致我的代码出现问题。

最新更新