[英]Vertically fixed slider to content below
I have an image slider on top of my website. 我的网站上方有一个图像滑块。 It's here on my hosting page with top slider
它在我的托管页面中,顶部滑块
I need to fix this slider vertically, so bottom content will scroll above my slider. 我需要垂直固定此滑块,因此底部内容将在我的滑块上方滚动。 When slider will stay like fixed block.
当滑块会像固定块一样停留。 I have the same example with image, this is the same page but instead of slider here is block with background image, and fixed background-attachment the same page with background image on top
我在图像上有相同的示例,这是同一页,但是这里的滑块不是背景图像,而是固定滑块,背景固定在同一页面上,背景固定在顶部
So in second link you can see effect what I want to apply with slider. 因此,在第二个链接中,您可以看到效果,我想对滑块应用。 Is it possible?
可能吗? I can't find way.
我找不到路。
Add this to your current css and it should have the effect you're seeking. 将此添加到当前的CSS中,它应具有您想要的效果。
.slider-bg {
position: relative;
z-index: -1;
height: 502px;
}
.flexslider {
position: fixed;
}
You need to set color for your .container
as well or create a new class/id name for all your sections (ie your .container) and apply a background color to it. 您还需要为
.container
设置颜色,或为所有部分(即.container)创建新的类/ id名称,并为其应用背景颜色。
Updated 更新
Since your slider have a buttons, setting its z-index to -1 would make the buttons unclickable, you need to set you .slider-bg
z-index to 1 and your 由于滑块具有按钮,因此将其z-index设置为-1会使按钮无法点击,因此您需要将
.slider-bg
z-index设置为1,然后将
.container {
position: relative;
z-index: 2;
background-color: #fff;
}
I guess you want Carousel. 我想你想要旋转木马。 The Carousel plugin is a component for cycling through elements, like a carousel (slideshow).
Carousel插件是一个用于在各个元素之间循环的组件,例如Carousel(幻灯片)。
Tip: Plugins can be included individually (using Bootstrap's individual "carousel.js" file), or all at once (using "bootstrap.js" or "bootstrap.min.js"). 提示:可以单独包含插件(使用Bootstrap的单个“ carousel.js”文件),也可以一次包含所有插件(使用“ bootstrap.js”或“ bootstrap.min.js”)。
Sample Code : 样例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<style>
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
width: 70%;
margin: auto;
}
</style>
</head>
<body>
<div class="container">
<br>
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>-->
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://www.w3schools.com/bootstrap/img_flower.jpg" alt="Chania" width="460" height="345">
</div>
<div class="item">
<img src="http://www.w3schools.com/bootstrap/img_flower2.jpg" alt="Chania" width="460" height="345">
</div>
<div class="item">
<img src="http://www.w3schools.com/bootstrap/img_flower.jpg" alt="Flower" width="460" height="345">
</div>
<div class="item">
<img src="http://www.w3schools.com/bootstrap/img_flower2.jpg" alt="Flower" width="460" height="345">
</div>
</div>
<!-- Left and right controls
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>-->
</a>
</div>
</div>
</body>
</html>
If you want more information in simplified way please visit this 如果您想以简化的方式获得更多信息,请访问此
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.