html - 为什么调整窗口大小时输入字段消失

标签 html css

当我调整浏览器窗口大小时,输入字段被截断了一点。我正在使用百分比,但它仍然被切断,我不知道为什么。我在下面提供了一个截图。 Screenshot如果我使用百分比,它不应该自动调整大小吗?谢谢!

这是我的 CSS 代码:

body {
    margin: 0;
    padding: 0;
    background-color: #EFEFEF;
    font-family: sans-serif;
}

.homepage-window {
    height: 100vh;
    display: flex;
}

.nav-bar {
    width: 18%;
    background-color: #2E3E4E;
}

.bar-manager {
    width: 100%;
}

.top-bar {
    display: flex;
    align-items: center;
    width: 100%;
    height: 7%;
    background-color: white;
    border-bottom: 0.5px solid lightgrey;
}

.top-bar p {
    margin-left: 10px;
    font-weight: lighter;
}

.user-search-input-field {
    margin-left: 70%;
    width: 190px;
    background-color: red;
}

.bottom-bar {
    width: 100%;
    height: 40px;
    display: flex;
    align-content: center;
    line-height: 40%;
    background-color: white;
    border-bottom: 1px solid lightgrey;
}

.bottom-bar h1 {
    font-size: 12px;
    margin-left: 10px;
    font-weight: 500;
}

.bottom-bar p {
    font-size: 12px;
    margin-left: 10px;
    font-weight: lighter;
}

这是我的 HTML 代码:

<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="CSS/Homepage.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<head>
    <title>Cold-Ops Homepage</title>
</head>
<body>
    <div class="homepage-window">
        <div class="nav-bar">   
        </div>
        <div class="bar-manager">
            <div class="top-bar">
                <p>Homepage</p>
                <div class="user-search-input-field">
                    <form action="Login.php" method="POST">
                        <input type="text" name="userPost" placeholder="Search users..." required>
                        <i class = "fa fa-search" aria-hidden = "true"></i>
                    </form>
                </div>
            </div>
            <div class="bottom-bar">
                <div class="bottom-bar-texts">
                    <div><h1>Welcome, Omard2000</h1></div>
                    <div><p>Administrator</p></div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

谢谢!

最佳答案

您已经定位了元素。

可能是左边把它推离了可见屏幕

此外,混合使用 View 单位和像素也很危险。

关于html - 为什么调整窗口大小时输入字段消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50780061/

相关文章:

javascript - 创建表格标题的双向固定滚动

html - 仅将 Bootstrap 'Col' 应用于平板电脑大小的设备

嵌套并设置为 100% 时的 HTML 表格高度,第二个表格与第一个表格重叠

javascript - 将 sortable.js 与 HTML 自定义数据属性结合使用

javascript - 将 Controller 添加到 ngRoute 时出现意外标识符

html - 如果不是子元素,纯 CSS 可以在悬停时更改其他元素吗?

HTML CSS - body 左半部分的中心图像

html - Internet Explorer 的目录上传

jquery - 鼠标移动太快时不触发事件

visual-studio-2010 - Visual Studio 2010 中的 HTML5 和 CSS3 智能感知