如何创建这样的javascript滑块?

时间:2017-10-25 08:18:48

标签: javascript jquery image slider

我想创建类似this的内容,但我不知道该怎么做。我想要移动的元素是相对父母中的position: absolute



  #next1 {
  position: absolute;
  width: 50%;
  top: 0;
  left: 0;
  height: 100%;
  background-image: url(../../../parkHargrave.com/album/device_crops/3.jpg);
  background-size: 150px;
  background-repeat: no-repeat;
  background-position: center;
  box-shadow: inset 0 0 0 2000px rgba(119, 136, 153, 0.60);
}

#mainImage {
  padding: 30px;
  height: 200px;
}

#next {
  position: absolute;
  width: 100%;
  top: 0;
  right: 0;
  height: 100%;
  background-image: url(../album/device_crops/merged.png);
  background-repeat: no-repeat;
  background-position: center;
}

#next2 {
  position: absolute;
  width: 50%;
  top: 0;
  right: 0;
  height: 100%;
  background-image: url(../album/device_crops/merged.png);
  background-size: 150px;
  background-repeat: no-repeat;
  background-position: center;
  box-shadow: inset 0 0 0 2000px rgba(119, 136, 153, 0.50);
  #mainImgContainer {
    height: 300px;
    position: relative;
    background-color: darkslategrey;
  }
  #nextContainer {
    position: relative;
    height: 200px;
    background-color: darkslategray;
  }
  #websiteInfo {
    background-color: white;
    background-size: cover;
    padding: 35px;
  }
  #theWineYardHeader {
    font-size: 30px;
    color: black;
    font-family: 'Montserrat', sans-serif;
    text-align: center;
    border-bottom: black;
    border-top: black;
    border-top-style: double;
    border-bottom-style: double;
    line-height: 1.3em;
  }
  #theWineYardText {
    font-size: 15px;
    border-style: solid;
    border-color: green;
    color: red;
    border-width: thin;
    padding: 5px;
    text-align: center;
    background-size: contain;
    display: inline-block;
  }

<div id="text2Content">
  <div id="mainImgContainer">
    <div id="next"></div>
  </div>
  <div id="websiteInfo">
    <p id="theWineYardHeader"> The Wine Yard </p>
    <img src="album/apple-computer-laptop-mac-monitor-screen-icon--icon-
    search--16.png" style="height:35px; margin:auto; margin-top:15px; margin-
    bottom:15px; display:block;">
    <p id="theWineYardText"><a href="thewineyard.ca">Visit Live 
    Website</a></p>
  </div>

  <div id="nextContainer">
    <div id="next1" class="image">
      <p><i class="arrow up"></i></p>
    </div>
    <div id="next2" class="image">
      <p><i class="arrow down"></i></p>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;

0 个答案:

没有答案