我创建了一个网页,发现了一些奇怪的问题。
当我尝试从主页进入子页面时,会显示子页面,但是向下滚动。它可能显示在顶部,而在计算机上显示 - 但不是在电话上。
有一个代码:
HTML(来自正文部分):
<div id="top"><a href="some_link">Go to main</a></div>
<div id="title" class="slide">
<div class="content">
<div class="space">
<span class="centerer"></span>
<span class="centered"><h1>Some centered stuff there</h1></span>
</div>
<div id="changelog_btn">
<a href="#changelog">
<span class="centerer"></span>
<span class="centered">Changelog</span>
</a>
</div>
<div id="dl_btn">
<a href="#download">
<span class="centerer"></span>
<span class="centered">Download</span>
</a>
</div>
<div class="space"></div>
</div>
</div>
<div id="changelog" class="slide">
<div class="content">
<div class="space">
<span class="centerer"></span>
<span class="centered"><h1>Changelog</h1><div class="up_btn"><a href="#top">(Top)</a></div></span>
</div>
<textarea readonly autofocus>
Some changelog stuff
</textarea>
</div>
<div class="space"></div>
</div>
<div id="download">
<div id="content" class="slide">
<div class="space">
<span class="centerer"></span>
<span class="centered"><h1>Download</h1><div class="up_btn"><a href="#top">(Top)</a></div></span>
</div>
Header<br>
<div id="dl_btn">
<a href="file.link" download>
<span class="centerer"></span>
<span class="centered">Download file</span>
</a>
</div>
<div class="space"></div>
</div>
</div>
的 CSS
@media only screen
and (min-device-width: 240px) {
html {
font-family: 'AtomicAge';
overflow-x: hidden;
background-attachment: fixed;
}
body {
margin: 0;
padding: 0;
background-attachment: fixed;
}
h1 {
margin: auto;
}
.space {
height: 25%;
display: block;
vertical-align: middle;
}
.slide {
width: 100vw;
height: 100vh;
text-align: center;
z-index: -1;
box-shadow: 0 -1px 10px rgba(0, 0, 0, .7);
}
#changelog_btn a, #dl_btn a {
display: inline-block;
vertical-align: top;
width: 20%;
height: 5%;
border: 1px solid;
margin: 15px auto;
}
#changelog_btn a, #dl_btn a {
text-decoration: none;
color: black;
transition: all 0.5s ease;
}
#changelog_btn a:hover, #dl_btn a:hover {
background-color: white;
}
textarea {
width: 80%;
height: 50%;
}
.centered, .centerer {
vertical-align: middle;
display: inline-block;
}
.centerer {
height: 100%;
}
.up_btn a {
text-decoration: none;
color: black;
transition: all 0.5s ease;
}
.up_btn a:hover {
color: white;
}
#title {
background-image: url("_images/bg1.jpg");
background-attachment: fixed;
background-size: cover;
}
#changelog:before, #changelog {
background-image: url("_images/bg2.jpg");
background-attachment: fixed;
background-size: cover;
}
#download {
background-image: url("_images/bg3.jpg");
background-attachment: fixed;
background-size: cover;
}
#top a {
display: inline-block;
width: 100%;
text-align: center;
color: white;
background-color: black;
text-decoration: none;
transition: all 0.5s ease;
}
#top a:hover {
color: black;
background-color: white;
}
}
@media only screen
and (max-width: 1080px) {
* {
margin: 0;
padding: 0;
background-attachment: fixed;
}
}
我能纠正什么吗?
答案 0 :(得分:0)
它似乎也在计算机上略微向下滚动(至少在我的屏幕上有点滚动)。我同意这个问题很奇怪。我建议在页面底部插入以下JavaScript:
<script>
window.onload = function () {window.scrollTo(0,0)};
</script>
答案 1 :(得分:0)
您已将自动对焦属性应用于文本区域:)