gpt4 book ai didi

javascript - 为表单添加滚动功能

转载 作者:太空宇宙 更新时间:2023-11-04 10:17:29 24 4
gpt4 key购买 nike

我面临的问题是我的表单在窗口上保持静态。但我想要的是 form_1 应该跳到窗口顶部,因为用户在“输入您的起始”城市文本框。

<html>
<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
img.bg {
min-height: 100%;
min-width: 1024px;

width: 100%;
height: auto;

position: fixed;
top: 0;
left: 0;
}

@media screen and (max-width: 1024px){
img.bg {
left: 50%;
margin-left: -512px; }
#form_1 {
width: 20%;
}
}

#form_1 {
position: relative;
border-radius: 15px;

width: 80%;
margin: 15% auto;
padding: 20px;
background: white;
-moz-box-shadow: 0 0 20px black;
-webkit-box-shadow: 0 0 20px black;
box-shadow: 0 0 20px black;
display: table;
border :solid 2px black;
padding: 15px;
}

.row {
display:table-row;
}

.row label {
text-align: right;
}
</style>
</head>
<body>

<div id="yt" >
<img src="bg.jpg" class="bg">
<form id="form_1" tabindex="0">
<label>Enter Starting City</label>
<div class="row">
<input type="text" name="s_city"></br>
</div>
<div class="row">
<label>Wait While The Cities Appear
</label></br>
<textarea rows="10" cols="30"></textarea></br>
<div class="row">
</form>
</div>

</body>
</html>

最佳答案

我注意到一些错误的标签和错误的关闭标签,修复它们,看看它是否有效。

<html>
<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
img.bg {
min-height: 100%;
min-width: 1024px;

width: 100%;
height: auto;

position: fixed;
top: 0;
left: 0;
}

@media screen and (max-width: 1024px){
img.bg {
left: 50%;
margin-left: -512px; }
#form_1 {
width: 20%;
}
}

#form_1 {
position: relative;
border-radius: 15px;

width: 80%;
margin: 15% auto;
padding: 20px;
background: white;
-moz-box-shadow: 0 0 20px black;
-webkit-box-shadow: 0 0 20px black;
box-shadow: 0 0 20px black;
display: table;
border :solid 2px black;
padding: 15px;
}

.row {
display:table-row;
}

.row label {
text-align: right;
}
</style>
</head>
<body>

<div id="yt" >
<img src="bg.jpg" class="bg" />
<form id="form_1" tabindex="0">
<label>Enter Starting City</label>
<div class="row">
<input type="text" name="s_city"><br/>
</div>
<div class="row">
<label>Wait While The Cities Appear</label><br/>
<textarea rows="10" cols="30"></textarea><br/>
</div>
</form>
</div>

</body>
</html>

关于javascript - 为表单添加滚动功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37121901/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com