我正在修改从http://tympanus.net/codrops/2012/03/15/parallax-content-slider-with-css3-and-jquery/获得的一些 CSS 代码。它是一个视差 CSS3 滑块。
我几乎尝试了所有方法,但我的问题是我无法在浏览器中以固定的最大宽度居中滑动 div(da.slide)。最大宽度为 970 像素,当浏览器调整大小时会缩小。我已经尝试使用margin: 0 auto
并且left:50%
它现在仍在工作 - 它只是挂在左边。
我认为可能的问题是滑块 div 的定位。当我将它从绝对更改为相对时,它适用于第一张幻灯片,但其余幻灯片消失/在彼此下方滑动。有没有机会使滑动 div 居中?
这是CSS3代码:
.da-slider{
width: 100%;
min-width: 320px;
height: 300px;
position: relative;
margin: 0 auto;
overflow: hidden;
background: transparent url(../images/waves.png);
background-repeat:repeat-x;
-webkit-transition: background-position 1s ease-out 0.3s;
-moz-transition: background-position 1s ease-out 0.3s;
-o-transition: background-position 1s ease-out 0.3s;
-ms-transition: background-position 1s ease-out 0.3s;
transition: background-position 1s ease-out 0.3s;
}
.da-slide{
position: absolute;
max-width: 970px;
width:100%;
height: 100%;
top: 0px;
left: 0px;
font-family: 'BebasNeueRegular', 'Arial Narrow', Arial, sans-serif;
text-align: left;
}
.da-slide-current{
z-index: 1000;
}
.da-slider-fb .da-slide{
left: 100%;
}
.da-slider-fb .da-slide.da-slide-current{
left: 0px;
}
.da-slide h2,
.da-slide p,
.da-slide .da-link,
.da-slide .da-img{
position: absolute;
opacity: 0;
left: 110%;
}
.da-slider-fb .da-slide h2,
.da-slider-fb .da-slide p,
.da-slider-fb .da-slide .da-link{
left: 10%;
opacity: 1;
}
HTML 是:
<div id="da-slider" class="da-slider">
<div class="da-slide">
<h2>Easy management</h2>
<p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean.</p>
<a href="#" class="da-link">Read more</a>
<div class="da-img"><img src="images/2.png" alt="image01" /></div>
</div>
<div class="da-slide">
<h2>Revolution</h2>
<p>A small river named Duden flows by their place and supplies it with the necessary regelialia. It is a paradisematic country, in which roasted parts of sentences fly into your mouth.</p>
<a href="#" class="da-link">Read more</a>
<div class="da-img"><img src="images/3.png" alt="image01" /></div>
</div>
<div class="da-slide">
<h2>Warm welcome</h2>
<p>When she reached the first hills of the Italic Mountains, she had a last view back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet Village and the subline of her own road, the Line Lane.</p>
<a href="#" class="da-link">Read more</a>
<div class="da-img"><img src="images/1.png" alt="image01" /></div>
</div>
<div class="da-slide">
<h2>Quality Control</h2>
<p>Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.</p>
<a href="#" class="da-link">Read more</a>
<div class="da-img"><img src="images/4.png" alt="image01" /></div>
</div>
<nav class="da-arrows">
<span class="da-arrows-prev"></span>
<span class="da-arrows-next"></span>
</nav>
</div>
任何帮助将不胜感激!