gpt4 book ai didi

javascript - 防止固定位置对象在特定位置随页面滚动

转载 作者:太空宇宙 更新时间:2023-11-04 12:58:20 25 4
gpt4 key购买 nike

我有这个page正如您所看到的,有一个菜单栏会在我滚动页面时滚动。那挺好的。但我希望它在遇到下方的特定对象时停止并随之向上滚动。

执行此操作的最佳方法是什么?谢谢你们。

这是 HTML:

<title>some theme</title>
<body>
<div id="Navigator">
<div class="logo">
<img class="svg" src="images/logo.svg" alt="My Logo" />
</div>
<ul>
<li><a href="#">Home</a>
</li>
</ul>
</div>
<div id="Container">
<div id="Content"></div>
</div>
<div id="Footer">
<div id="Links"></div>
<div id="CopyRight"></div>
</div>
<div class="content">
<div class="post">
<h2>Post 1</h2>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tempus, nisi ac fermentum rhoncus, leo elit luctus ex, id lobortis magna <a href="http://shahinism.github.io">Here is a link</a> libero ac orci. Integer eu ligula eu velit suscipit pretium nec ac turpis. Duis nec metus posuere, gravida lorem quis, gravida orci. Vestibulum blandit ultricies egestas. Aenean quis sagittis urna. Morbi nisi risus, vulputate sit amet ante nec, facilisis scelerisque ex. Aenean sagittis tempus nibh, at pellentesque leo venenatis eget. Cras eleifend turpis ipsum, nec tempus magna commodo malesuada. Aenean dignissim ex id tincidunt molestie.</p>
<p>Quisque congue vehicula cursus. Donec quis elit augue. Nulla augue felis, venenatis non sem at, aliquam porttitor libero. Sed pellentesque, ex quis imperdiet aliquet, diam velit tincidunt dolor, quis lacinia massa leo vitae risus. Vestibulum eget tincidunt augue. Pellentesque sollicitudin, urna ac porttitor sollicitudin, eros nisl porttitor urna, a volutpat nunc tortor sed diam. Sed fermentum elit at pellentesque aliquam. Praesent interdum odio id elit sodales semper. Morbi dapibus accumsan faucibus. Proin tincidunt nulla eu neque sodales convallis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec dignissim tincidunt tempor. Praesent a molestie ligula. Vivamus tempus massa nec enim finibus, in facilisis risus convallis. Proin efficitur euismod tristique.</p>
<p>Integer feugiat nunc vel blandit fermentum. Vestibulum tristique et metus vitae condimentum. Phasellus malesuada scelerisque tincidunt. Aliquam a pharetra magna, vitae finibus urna. Sed ante nisi, consectetur eget interdum a, venenatis ac lorem. Vivamus dignissim justo non mauris placerat, sed pulvinar sapien eleifend. Pellentesque commodo malesuada nulla, sit amet aliquam ipsum consectetur id. Mauris sagittis sapien at scelerisque hendrerit. Vivamus elementum lacus ac ultricies dictum. Praesent imperdiet eleifend odio in interdum. Aenean quis nunc massa. Duis at tellus vel quam hendrerit faucibus at vitae sem. Praesent ut mi rutrum, rutrum lorem eget, placerat metus.</p>
</div>
</div>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$(".placeholder-input").on("blur", function() {
$(this).toggleClass("not-empty", !! $(this).val());
});
</script>

和 CSS:

/* Color definitions
------------------------------- */

/* Reset base html elements */
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
html, body, ol {
margin: 0;
padding: 0;
}
body {
background: #fdf6e3;
font-family:"Open Sans";
}
#Navigator {
background-color: #002b36;
bottom: 0;
position: fixed;
left: 0;
width: 100%;
height: 44px;
border-top: 5px solid #268bd2;
padding: 0;
}
#Navigator ul {
width: 75%;
margin: 0 10px;
padding: 0px;
}
#Navigator ul li {
float: left;
list-style: none;
}
#Navigator ul li a {
color: #fdf6e3;
border-left: 0px solid #dc322f;
text-decoration: none;
display: block;
padding: 12px 10px;
display: block;
width: 63px;
height: 24px;
text-align: center;
transition: all 0.25s;
}
#Navigator ul li a:hover {
background: #268bd2;
border-left-width: 5px;
}
#Navigator .logo {
float: left;
width: 9%;
height: 44px;
}
#Navigator .logo img {
height: 43px;
margin: 0 10px;
}
#Navigator .search {
float: right;
width: 20%;
font-size: 16px;
}
#Navigator .search .field {
height: 40px;
position: relative;
}
#Navigator .search .field .placeholder-label {
position: absolute;
font-weight: 300;
color: #333333;
cursor: text;
z-index: 200;
transition: all 0.25s;
top: 10px;
left: 8px;
}
#Navigator .search .field .placeholder-label:after {
content:":";
opacity: 0;
color: #fdf6e3;
transition: all 0.25s;
}
#Navigator .search .field .placeholder-input {
background: #93a1a1;
top: 5px;
position: absolute;
width: 180px;
padding: 7px;
border-radius: 6px;
border: 1px solid #657b83;
font-size: 14px;
z-index: 100;
transition: all 0.25s;
}
#Navigator .search .field .placeholder-input:focus, #Navigator .search .field .placeholder-input.not-empty {
margin-left: 70px;
width: 110px;
}
#Navigator .search .field .placeholder-input:focus + .placeholder-label, #Navigator .search .field .placeholder-input.not-empty + .placeholder-label {
cursor: default;
color: #fdf6e3;
}
#Navigator .search .field .placeholder-input:focus + .placeholder-label:after, #Navigator .search .field .placeholder-input.not-empty + .placeholder-label:after {
opacity: 1;
}
.content .metadata {
float: left;
width: 17%;
padding: 10px;
font-size: 11px;
color: #93a1a1;
}
.content .post {
text-align: justify;
float: left;
width: 60%;
background-color: white;
border-width: 0 10px;
border-color: #eee8d5;
border-style: solid;
padding: 10px;
}
.content a {
color: #268bd2;
text-decoration: none;
padding-bottom: 3px;
padding: 0;
position: relative;
}
.content a:after {
content:"";
background: none repeat scroll 0 0 #d33682;
position: absolute;
height: 1px;
bottom: 0;
left: 50%;
right: 50%;
transition: all 0.25s;
}
.content a:hover:after {
height: 2px;
left: 0;
right: -4px;
}
.content a:hover {
color: #d33682;
}
.content a:visited {
color: #6c71c4;
}
.content a:visited:hover {
color: #d33682;
}

最佳答案

关于javascript - 防止固定位置对象在特定位置随页面滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25642242/

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