我在移动设备上显示联系表单时溢出时遇到问题



问题基本上是,每当我在手机上显示这个表单时,当我在表单中输入文本时,文本区域扩展得太大,超过了Submit按钮和页脚。当我单击文本区域外部时,它保持展开状态,但是提交按钮和页脚返回到文本区域下方的位置。我做错了什么?我在这里提供了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;
}

我认为这可能是由于移动网站的视口缩放造成的。一旦你在文本区域中输入任何字符,移动视口缩放会将行高放大10px,这将使文本区域的高度增加cols * 10px。在你的代码中,它又增长了400px。我有两个解。

  1. 设置文本区域的固定高度。根据您的情况,您可以设置文本区域的高度为cols * line-height。假设你的文本的行高是18px和cols="40",你可以设置height:18*40=720px;

  2. 您可以添加:

    <head><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /></head>

,并设置文本区域的宽度为100%。

最新更新