问题基本上是,每当我在手机上显示此表单时,当我向表单中输入文本时,textarea 扩展太多并越过提交按钮和页脚。当我在文本区域外单击时,它保持展开状态,但提交按钮和页脚返回到它们在文本区域下方的位置。我究竟做错了什么?我在这里提供了 html 和 css。是什么导致了类似的事情发生,我该如何解决?
我只想让它保持合理的大小。在桌面上加载时似乎没有任何问题。它似乎只发生在手机上。
这是 HTML
<!DOCTYPE html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" /> </head>
<body>
<form action="success.php" method="POST" onSubmit="return validateTextbox();" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit"> Full Name:
<input id="fullname" name="name" type="text" value="" size="40" placeholder="First and Last Name" />
<br>
<br> Your Email:
<input id="youremail" name="email" type="email" value="" size="40" placeholder="Enter your Email" />
<br>
<br>
<!--How do you want your transcript?<br><br>
<input type="radio" name="transcript_type" value="verbatim"/>Verbatim
<input type="radio" name="transcript_type" value="non_verbatim"/>Non- Verbatim
<input type="radio" name="transcript_type" value="unknown"/>Don't Know Yet<br><br>-->Your Message:
<br>
<br>
<textarea id="messageArea" name="message" rows="40" cols="80" placeholder="Enter your message here (10 character minimum.)"></textarea>
<br>
<input type="submit" value="Submit" onclick="return val();" /> </form>
</body>
</html>
这就是 CSS
body {
background-color: black;
}
form {
/*border-style: solid;
border-right-style: none;
border-left-style: none;*/
padding-top: 100px;
text-align: center;
width: 100%;
background-size: cover;
background-image: url(images/starbright_avw.png);
margin-top: 20px;
color: white;
}
label {
font-family: impact;
}
/*
text-align: center;
margin-top: 40px;*/
input[type="submit"] {
height: 50px;
border-radius: 5px;
border-style: solid;
border-color: black;
color: black;
margin-bottom: 50px;
margin-top: 10px;
}
.row {
margin-top: 20px;
}
p.message {} p.yourMessage {
font-family: impact;
color: blue;
}
最佳答案
我认为这可能是移动网站视口(viewport)缩放引起的。一旦您在文本区域中键入任何字符,移动视口(viewport)缩放会将行高放大 10px,这会将文本区域的高度增加 cols * 10px。在您的代码中,它又增长了 400 像素。我有两个解决方案。
为文本区域设置固定高度。至于你的情况,你可以设置textarea的高度为
cols
*line-height
.假设您的文本行高是 18px 和cols="40"
, 你可以设置height:18*40=720px;
.您可以添加:
<head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /></head>
并将文本区域的宽度设置为100%。
关于html - 我的联系人表单在移动设备上显示时出现溢出问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40275018/