asimryu

20150924 opacity test

Sep 24th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.12 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title></title>
  6. <style>
  7.     body { margin:0;}
  8.     header {
  9.         position: relative;
  10.     }
  11.     #bg {
  12.         position: absolute;
  13.         top: 0;
  14.         left: 0;
  15.         width: 100%;
  16.         height: 986px;
  17.     }
  18.     #bg > div {
  19.         position: absolute;
  20.         top: 0;
  21.         left: 0;
  22.         width: 100%;
  23.         height: 986px;
  24.         background-position: center bottom;
  25.         opacity: 0;
  26.     }
  27.     #bg1, #main1 {
  28.         background-image: url(http://livedemo00.template-help.com/opencart_55380/image/cache/catalog/slide-1-2050x986.jpg);
  29.     }
  30.     #bg2, #main2 {
  31.         background-image: url(http://livedemo00.template-help.com/opencart_55380/image/cache/catalog/slide-2-2050x986.jpg);
  32.     }
  33.     #bg3, #main3 {
  34.         background-image: url(http://livedemo00.template-help.com/opencart_55380/image/cache/catalog/slide-3-2050x986.jpg);
  35.     }
  36.     #maincontainer {
  37.         position: relative;
  38.         margin: 0 auto;
  39.         width: 1200px;
  40.         height: 836px;
  41.         top: 150px;
  42.     }
  43.     #maincontainer > div {
  44.         position: absolute;
  45.         left:0;
  46.         top: 0;
  47.         width: 1200px;
  48.         height: 836px;
  49.         background-position: center bottom;
  50.         opacity: 0;
  51.     }
  52.     #main-bottom {
  53.         position: absolute;
  54.         left:0;
  55.         top: 836px;
  56.         width: 1200px;
  57.         height: 836px;
  58.         width:100%;
  59.         height:150px;
  60.         background-color: white;
  61.     }
  62.  
  63. </style>
  64. </head>
  65. <body>
  66. <header>
  67.     <div id="bg">
  68.         <div id="bg1"></div>
  69.         <div id="bg2"></div>
  70.         <div id="bg3"></div>
  71.     </div>
  72.     <div id="main-bottom"></div>
  73.     <div id="maincontainer">
  74.         <div id="main1"></div>
  75.         <div id="main2"></div>
  76.         <div id="main3"></div>
  77.     </div>
  78. </header>
  79. <script src="http://code.jquery.com/jquery-latest.js"></script>
  80. <script>
  81.     var sno=0;
  82.     var bgslides = $("#bg > div");
  83.     var mainslides = $("#maincontainer > div");
  84.     $(bgslides[sno]).css({"opacity":0.9});
  85.     $(mainslides[sno]).css({"opacity":1});
  86.     var max=bgslides.length - 1;
  87.     function bgslide(){
  88.         $(bgslides[sno]).animate({"opacity":0},500);
  89.         $(mainslides[sno]).animate({"opacity":0},500);
  90.         sno++;
  91.         if(sno > max) sno = 1;
  92.         $(bgslides[sno]).animate({"opacity":0.9},500);
  93.         $(mainslides[sno]).animate({"opacity":1},500);
  94.     }
  95.     var timer = setInterval(function(){ bgslide(); },3000);
  96. </script>
  97. </body>
  98. </html>
Advertisement
Add Comment
Please, Sign In to add comment