html - CSS和Html调整登录表单高度而不挤压小屏幕上的文本框?
问题描述
我有一个登录表单,当在较小的屏幕上查看时,文本框会被压缩到一个非常窄的高度。当我为父级login-form
和login-container
容器设置高度时,父级的高度会增加,但文本框不会增加,它们仍然很窄。
Q:小屏观看时如何让高度变高?
html:
<!-- Login form -->
<div class="login-form animate" >
<form action= "" method="post">
<div class="login-container ">
<h2>Welcome!</h2>
<input type="text" placeholder="Username.." name="uname" id="uname" required>
<input type="password" placeholder="Password.." name="passw" id="passw" required>
<input type="hidden" name="token" id="token" value= <?php echo $_SESSION["loggedin"] ?> >
<button class="logbut" type="submit" name="login" id="login">Login</button>
</div>
</form>
<form action= "index.php" method="post">
<div class="login-container ">
<label>
<input class="pswreset" type="submit" name="forgot" id="forgot" value="Forgot password?">
</label>
</div>
</form>
</div>
CSS:
.login-container {
padding: 16px;
}
.login-form {
left: 1%;
right: 1%;
position: absolute;
width:25%;
text-align: center;
margin-right:auto;
margin-left:auto;
display: grid;
grid-template-columns: auto;
align-content: center;
background-color: #FFFFFF;
border-radius: 4px;
}
/*Small media devices specific styles*/
@media screen and (max-width: 800px) {
/*-------------Login page------------*/
.login-form, .login-topnav {
width: 100%;
max-width:100%;
margin: 0px;
padding: 0px;
}
.login-container {
margin: 0px;
width: 100%;
max-width:100%;
padding: 0px;
}
}
解决方案
所以我解决了我的问题。您只需将各个文本框设置为所需的高度单位,在我的情况下,6vh Relative to 1% of the height of the viewport*
即:
/*Small media devices specific styles*/
@media screen and (max-width: 800px) {
/*-------------Login page------------*/
input[type=text], input[type=password], input[type=email] {
width: 99%;
padding: 0px;
height: 6vh;
}
推荐阅读
- javascript - 如何更改从没有状态的父级传递的子组件值
- powershell - 解析文本文件或 html 文件以创建表格
- facebook-graph-api - 用于管理页面直播的 Facebook Graph API Webhook
- c++ - 对元组进行三角化
- javascript - div 在表单内时的 div 点击事件
- replace - 子字符串的基本 LISP 递归替换
- elasticsearch - 如何将搜索查询参数传递给弹性搜索 url
- mongodb - Elixir 和 mongodb 聚合
- vb.net - VB.NET - 在流关闭之前不发送数据
- r - mutate_all 在 r 中的列表上使用 map 和 case_when / ifelse