从右边滑动横幅

时间:2015-03-19 08:47:16

标签: jquery banner

我真的很怀疑我是如何制作剧本的。我正在制作一面旗帜,并得到了来自这里的人们的帮助。非常感谢你。这是它到目前为止的样子:

Banner Video On Youtube

我想从右边滑入一条透明线,然后停在黄线上:

Picture

但是我如何开始使用这个脚本?到目前为止,我的代码看起来像这样。

<html>

<head>
<link rel="stylesheet" type="text/css" href="bannerTest.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
    $(document).ready(function() {
        $(".banner").animate({height: "300px"}, 600);
        $(".banner").animate({width: "100%"}, 120, function() {
            $(".banner-blue").animate({height: "300px"}, 700);
            });
            $(".banner-blue").animate({
            height: "300px"
            }, 700, function(){
            $('.hidden').fadeIn();
            });

    });
</script>
</head>

<body>

<div class="banner">
    <div class="banner-blue">
        <p class="hidden" id="text1">99 Kr</p>
        <p class="hidden" id="text2">| Det tager maks 2 timer |</p>
    </div>
</div>
</body>
</html>

CSS:

.banner {
    background:#0FB493;
    height:100px;
    width:300px;
    margin:6px;
}

.banner-blue {
    background:#0f9fb4;
    position:absolute;
    width: 300px;
}

.hidden {
    display: none;

}

#text1 {
    font-family: 'Open Sans';
    font-size: 40px;
    color: black;
    font-weight: lighter;
    padding-left: 160px;
}

#text2 {
    font-family: 'Open Sans';
    font-size: 20px;
    color: black;
    font-weight: lighter;
    padding-left: 10px;
}

最诚挚的问候 MADS

2 个答案:

答案 0 :(得分:0)

这应该接近你想要的(单击运行代码片段以查看结果):

&#13;
&#13;
$(document).ready(function() {
  $(".banner").animate({
    height: "300px"
  }, 600);

  $(".banner").animate({
    width: "100%"
  }, 120, function() {
    $(".banner-blue").animate({
      height: "300px"
    }, 700);
  });
  $(".banner-blue").animate({
    height: "300px"
  }, 700, function() {
    $('.hidden').fadeIn();
    $(".line").animate({
      marginLeft: "300px"
    }, 2000);
  });


});
&#13;
.banner {
  background: #0FB493;
  height: 100px;
  width: 300px;
  margin: 6px;
}
.banner-blue {
  background: #0f9fb4;
  position: absolute;
  width: 300px;
}
.line {
  background: gray;
  opacity: 0.7;
  width: 100%;
  height: 100px;
  margin-left: 1500px;
}
.hidden {
  display: none;
}
#text1 {
  font-family: 'Open Sans';
  font-size: 40px;
  color: black;
  font-weight: lighter;
  padding-left: 160px;
}
#text2 {
  font-family: 'Open Sans';
  font-size: 20px;
  color: black;
  font-weight: lighter;
  padding-left: 10px;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="banner">
  <div class="banner-blue">
    <p class="hidden" id="text1">99 Kr</p>
    <p class="hidden" id="text2">| Det tager maks 2 timer |</p>
  </div>
  <div class="line"></div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

这样的东西可能对你有用

http://jsfiddle.net/vukdkoc4/

它使用css calc()属性作为宽度来考虑屏幕大小