簡體   English   中英

在幻燈片中的圖像上添加漸變漸變

[英]Adding a fading gradient over image in slide

我試圖在幻燈片放映的圖像上添加漸變漸變,這樣,當觀看某張圖片時(我的幻燈片顯示3張照片,一張中間,然后是第一張和上一張照片的一小部分),雙方將在它們上面有這個漸變,所以左邊的前一張圖片會讓它的左側淡出,反之亦然。 如果你找到我? 與此處評論的內容類似: 如何在CSS中對圖像應用淡入淡出? 我有2個.png's ,一個向左淡化,一個向右淡化。 我在哪里應用這些HTML.css 你會在.css最底部看到它們,但它們沒有正確應用,並且在html中沒有相應的div(需要?)。 當您將鼠標懸停在下一張&上一張圖像上時,它們也應該減輕一點(丟失一些淡入淡出效果)。 示例: http//www.deadmau5.com

HTML

<div class="hero">
    <div class="hero-carousel">

        <article>
          <img src="images/deadmau5/slide1.jpg" />
        </article>

        <article>
          <img src="images/deadmau5/slide2.jpg" />
        </article>

        <article>
          <img src="images/deadmau5/slide3.jpg" />
        </article>

        <article>
          <img src="images/deadmau5/slide4.jpg" />
        </article>

    </div>
</div>

JavaScript的

<script>
    $(document).ready(function(){
        $('.hero-carousel').heroCarousel({
            easing: 'easeOutExpo',
            css3pieFix: true
        });
    });
</script>

CSS

.hero {
    width: 1366px;
    height: 340px; position:absolute;top:270px;
    overflow: hidden;
    margin-bottom: 48px;
    margin: 0 auto;
    border-top:9px solid rgba(51, 51, 51, .15);
    border-bottom: 9px solid rgba(51, 51, 51, .15);
    padding: 0 0 12px 0;
}

.hero-carousel article {
    width: 970px;
    margin: 0 auto;
    height: 470px;
    display: block;
    float: left;
    position: relative;
}

.hero-carousel-container article {
    float: left;
}

.hero-carousel article img{
    border-style:solid;border-width:6px;color:#000; position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.hero-carousel article .contents {
    position: relative;
    z-index: 2;
    top: 72px;
    left: 48px;
    list-style: none;
    color: #000;
    width: 556px;
    padding: 20px;

    background: rgba(255,255,255,0.8);
    -pie-background: rgba(255,255,255,0.8);

    -moz-border-radius: 20px;
    -webkit-border-radius: 20px;
    border-radius: 20px;

    behavior: url(/assets/PIE.htc);
}

.hero-carousel-nav {
    width: 980px;
    position: absolute;
    bottom: 0;
    left: 50%;
    margin-left: -490px;
    z-index: 2;
}

.hero-carousel-nav li {
   position: absolute;
   bottom: 48px;
   right: 48px;
   list-style: none;
}

.hero-carousel-nav li.prev {
    left: -50px;
    right: auto;
    bottom: 100px;
}
.hero-carousel-nav li.next {
    right: -30px;
    left: auto;
    bottom: 100px;
}

.hero-carousel-nav li a {     
    background: none repeat scroll 0 0 #D21034; 
    color: #FFFFFF;
    display: block;
    float: left;
}

.hero-carousel-nav li.next a { 
    background: url('../images/deadmau5/large-arrow-right.png'),
                -5px -7px no-repeat;
    display: inline-block;
    width: 105px;        /*width of your img*/
    height: 105px;      /*height of your img*/
    font-size: 0px; 
    right: -15px;  /*this is better than 1px*/
    bottom: 100px;
    overflow:hidden;
    outline:none;
}

.hero-carousel-nav li.prev a { 
    background: url('../images/deadmau5/large-arrow-left.png'),
                -7px -7px no-repeat;
    display: inline-block;
    width: 105px;        /*width of your img*/
    height: 105px;      /*height of your img*/
    font-size: 0px;    /*this is better than 1px*/
    left: -50px;
    bottom: 100px;
    overflow:hidden;
    outline:none;
}

有幾種方法可以解決這個問題,但這是一個簡單的例子,說明了這個網站如何鋪設一切。

CSS

#container {
    position: relative;
    width: 504px;
    margin: 0 auto;
}

#slide-container {
    width: auto;
}

.article {
    display: inline-block;
}

.article img {
    width: 165px;
    height: auto;    
}

#overlay-left {
    position: absolute;
    width: 165px;
    height: 60px;
    top: 0;
    left: 0;
    background: url('http://www.deadmau5.com/wp-content/themes/deadmau5/images/slider-fade-left.png') no-repeat top left;
    z-index: 2;
}

#overlay-right {
    position: absolute;
    width: 165px;
    height: 60px;
    top: 0;
    right: 0;
    background: url('http://www.deadmau5.com/wp-content/themes/deadmau5/images/slider-fade-right.png') no-repeat top right;
    z-index: 2;
}

#overlay-left:hover, #overlay-right:hover {
    opacity: 0.8;
}
​

HTML

<div id="container">
    <div id="slide-container">
        <div class="article">
            <a href="">
                <img src="http://www.deadmau5.com/wp-content/uploads/2012/06/slide1.jpg" />
            </a>
        </div>
        <div class="article">
            <a href="">
                <img src="http://www.deadmau5.com/wp-content/uploads/2012/06/slide1.jpg" />
            </a>
        </div>
        <div class="article">
            <a href="">
                <img src="http://www.deadmau5.com/wp-content/uploads/2012/06/slide1.jpg" />
            </a>
        </div>
    </div>
    <div id="overlay-left"></div>
    <div id="overlay-right"></div>
</div>

這里就是一個的jsfiddle如果你想用它玩。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM