每当我单击输入字段时,如何停止以纵向视图从移动浏览器的html表单从浮动视图右移到横向视图?

时间:2018-08-28 09:42:49

标签: html css forms mobile media-queries

我尝试使用float,overflow,clear,但我的html表单仍然继续正确浮动。我的预期结果是,当我去填写表单时,html表单可以在移动设备上保持纵向显示。

这是桌面平台上我的html表单的当前CSS代码:

form 
{
border: 10px solid #D3D3D3;
border-radius: 4px;
background: #D3D3D3;
width: 174px;
height: 306px;
position: absolute;
top: 212px;
left: 1168px;
font-family: "Arial", "Times New Roman", "Sans Serif";
font-style: normal;
text-decoration: none;
}
.FormHeading
{
text-decoration: underline;
font-weight: bold;
position: relative;
left: 29px;
}
input[type=text]
{
width: 168px;
}
textarea
{
resize: none;
box-sizing: border-box;
position: relative;
top: -23px;
left: 01px;
width: 173px;
}

input[type=submit]
{
background-color: #ADD8E6;
position: relative;
top: -40px;
left: 121px;
text-align: center;
}

这是我在移动设备上的html表单的当前代码:

    <form name = "CommentsForm" action ="Actionpage.php" onsubmit="return       
    validateForm()" method="post">
    <u class = "FormHeading">Send Comment</u><br>
    <br>
    First Name:<br>
    <input type="text" name="firstname">
    <br>
    <div style = "position: relative; top: 4px; left: 01px;">
    Last Name:<br>
    <input type="text" name="lastname">
    </div>
    <br>
    <div style = "position: relative; top: -13px; left: 1px;">
     Email:<br>
    <input type="text" name="email">
    </div>
    <br>
    <div style = "position: relative; top: -24px; left:03px;">
    <label for="comment"> Comment:</label></div>
    <textarea id="comment" name="comment" placeholder="Type commment              
    here" style="height: 69px;">
    </textarea>
    <br>
    <br>
    <input type="submit" name ="submit" value="Send" >
    </form>

This is the css for the html form on my mobile website:

form 
{ 
border: 10px solid #D3D3D3; 
border-radius: 4px;
background: #D3D3D3;
width: 176px;
height: 319px;
position: absolute;
top: 620px; 
left: 91px;
font-family: "Arial", "Times New Roman", "Sans Serif"; 
font-style: normal;
text-decoration: none;
float: none;
}
.FormHeading
{
text-decoration: underline;
font-weight: bold;
position: relative;
left: 29px;
}
input[type=text]
{
width: 168px;
float: none;
}
input[type=text]:focus
{
float: none;

}
textarea
{
resize: none;
box-sizing: border-box;
position: relative;
top: -23px;
left: 01px;
width: 173px;
float: none;
}

input[type=submit]
{
background-color: #ADD8E6;
position: relative;
top: -44px;
left: 119px;
text-align: center;
}

请注意,我有HTC需求626,因此我正在设计移动网站。

0 个答案:

没有答案