gpt4 book ai didi

html - 为什么我的页面自动滚动到底部/

转载 作者:行者123 更新时间:2023-12-02 01:03:41 27 4
gpt4 key购买 nike

<分区>

我在一个网站上工作,不知何故,每当我加载该网站或单击一个链接时,它都会跳到底部。

当我从 application.html.erb 文件中删除页脚时,网站没有滚动到底部。但我想保留页脚。有谁知道问题出在哪里或我该如何预防?

application.html.erb
<!DOCTYPE html>
<html>

<head>
<title>NightJobs</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body>
<%= render 'layouts/header' %>
<div id="content"></div>
<div id="container">
<%= yield %>
</div>
<%= render 'layouts/footer' %>
</body>
</html>

Layouts _footer.html.erb

<nav class="footer">
<div class="footer-link-container">
<ul>
<li><%= link_to "Home", root_path,class: "link-new" %></li>
<li><%= link_to "Help", help_path,class: "link-new" %></li>
<li><%= link_to "Contact", contact_path,class: "link-new" %></li>
<li><%= link_to "About", about_path,class: "link-new" %></li>
</ul>
</div>

<div class="subscribe-container">
<section class="subscribe">
<div class="subscribe-pitch subscribe-pitch-new">
<%= image_tag("envelope.png", alt: "envelope icon", :class => "envelope")%>
<p>Sign up for<br> daily updates<p>
</div>
<form action="index.html" method="post" class="subscribe-form">
<input type="email" name="email" class="subscribe-input" id="subscribe-spacing" placeholder="Email" autofocus>
<form action="index.html" method="post" class="subscribe-form">
<input type="email" name="email" class="subscribe-input" id="subscribe-spacing" placeholder="Zip Code" autofocus>
<button type="submit" class="tfbutton tfubutton-subscribe">Sign Up</button>
</form>
</section>
</div>

_footer.html.erb 类和 id 的 CSS

/* footer */

.footer {
text-align: center;
height: 170px;
clear: both;
position: relative;
z-index: 10;
margin-top: -3em;
background-color: #090909;
}

.footer-link-container{
width: 300px;
margin-left: 100px;
}

.footer li{
position: relative;
float: left;
margin-top: 100px;
display: inline-block;
margin-top: 35px;
}

.link-new{
position: relative;
padding: 20px;
color: $grayLight;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 14px;
font-weight: normal;
line-height: 20px;
text-decoration: none solid rgb(51,51,51);
word-spacing: 0px;
}

.link-new:hover{
color: white;
text-decoration: none;
}

/* Newsletter */

.subscribe-container {
height: 120px;
width: 300px;
position: relative;
float: right;
margin-right: 100px;
padding: 20px 20px 0px 20px;
margin-top: -40px;
border: solid 2px white;
background-color: #b5d77c;
}


.subscribe-form{
position: relative;
margin-top: -5px;
margin-left: 120px;
}

.subscribe-input{
width: 140px;
height: 15px !important;
margin-bottom: 70px;
top-padding: 100px;
line-height: 5px;
font-size: 5px;
}

#subscribe-spacing{
margin-bottom: 13px !important;

}
.subscribe-pitch{
margin-top: -5px;
margin-left: 10px;
bottom-padding: 50px;
width: 90px;
float: left;
color: #090909;
}


.envelope{
height: 60px;
width: 60px;
}


.tfubutton-subscribe {
margin-bottom: 10px !important;
margin-right: 60px !important;
width: 100px !important;
height: 30px !important;
padding: 5px 25px;
font-family: Arial, Helvetica, sans-serif;
font-size:14px;
outline: none;
text-align: center;
text-decoration: none;
color: #ffffff;
border: solid 1px #0076a3; border-right:0px;
background: #0095cd;
background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5));
background: -moz-linear-gradient(top, #00adee, #0078a5);
border-top-right-radius: 5px 5px;
border-bottom-right-radius: 5px 5px;
}

.tfbutton:hover {
text-decoration: none;
background: #007ead;
background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
background: -moz-linear-gradient(top, #0095cc, #00678e);
}

/* Fixes submit button height problem in Firefox */
.tfbutton::-moz-focus-inner {
border: 0;
}

如果您需要更多信息,请告诉我

更新:

问题似乎出在页脚中的订阅部分。我暂时删除了订阅框,这解决了问题。我认为这与 HTML 有关,因为当我删除 CSS 时,页面仍然跳到底部。

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