繁体   English   中英

如何使用CSS3和JQuery在轮播背景上实现缩放效果

[英]How to achieve a zooming effect on a carousel background using CSS3 and JQuery

我想添加一个与本网站轮播中相同的背景缩小效果。我无法为网页设计提供新的解决方案。

这是我要应用该效果的div的代码:

标记:

<div class="banner">
        <div class="content block1 animated">
          <h1>Ceramic Directory</h1>
          <span>World's largest Ceramic hub, all the ceramic traders reside here!</span>
          <a href="#">Register now</a>
          <span class="handler">&rarr;</span>
        </div>
</div>

CSS:

     .banner{
    margin-bottom: 10px;
    background-image: url("../images/png.jpg");
    background-repeat: no-repeat;
    height: 700px;
    background-size: cover;
    width: 100%;
  }
  .banner .block1{
    background-color: rgba(256,256,256,0.7);
    margin-top: 10%;
    height: 300px;
    position: absolute;
    width: 90%;
    padding-top: 7%;
    animation-name: fadein;
    -webkit-animation-name: fadein;
  }
  .banner .block1 h1{
    text-align: center;
    font-family: LatoWebLight;
    font-size: 40px;
    margin-bottom: 5px;
  }
  .banner .block1 span{
    text-align: center;
    font-family: LatoWebHairline;
    font-size: 25px;
    margin-bottom: 30px;
    display: block;
  }
  .banner .block1 a{
    text-align: center;
    border-radius: 5px;
    border: 1px solid black;
    font-family: LatoWebMedium;
    font-size: 18px;
    margin-left: 45%;
    margin-top: 5%;
    padding: 10px;
    text-decoration: none;
    color: black;
  }

  .banner .block1 .handler{
    text-align: center;
    border-radius: 5px;
    border: 1px solid black;
    cursor: pointer;
    font-size: 18px;
    margin-left: 105%;
    margin-top: -5%;
    padding: 10px;
    color: black;
    width: 20px;
    transition: color 0.2s;
    -webkit-transition: color 0.2s;
    transition: background 0.2s;
    -webkit-transition: background 0.2s;
  }
  .banner .block1 .handler:hover{
    font-weight: 900;
    background: rgba(34,34,34,0.5);
    color: white;
  }

他们是怎么做到的?

谢谢您的帮助

您提到的网站使用jQuery插件对标题图像进行动画处理。 你可以找到插件的页面在这里和一些详细的文档在这里

如果您不打算使用插件,则可以使用CSS3实现图像缩放效果。 下面是相同的示例:

 .test { width: 300px; height: 300px; position: relative; left: 30px; top: 30px; transition: all 1s; } .test:hover { -webkit-transform: scale(1.05, 1.05); transform: scale(1.05, 1.05); } .test:after { content: ''; position: absolute; left: 0px; top: 0px; right: 0px; bottom: 0px; background: url("http://lorempixel.com/600/400"); background-size: cover; } 
 <div class="test"> </div> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM