カルーセル

In this example below you will see how to do a カルーセル with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by JunkiSuzuki, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright JunkiSuzuki ©
  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>カルーセル</title>
  
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <p>a</p>
<p>b</p>

<div class="slider-wrapper">
  <div class="slider">
    <div class="unit">
      <p class="img"><img src="" alt="" /></p>
      <p class="caption">キャプションです。</p>
    </div><!-- /.unit -->
    <div class="unit">
      <p class="img"><img src="" alt="" /></p>
      <p class="caption">キャプションです。</p>
    </div><!-- /.unit -->
    <div class="unit">
      <p class="img"><img src="" alt="" /></p>
      <p class="caption">キャプションです。</p>
    </div><!-- /.unit -->
    <div class="unit">
      <p class="img"><img src="" alt="" /></p>
      <p class="caption">キャプションです。</p>
    </div><!-- /.unit -->
    <div class="unit">
      <p class="img"><img src="" alt="" /></p>
      <p class="caption">キャプションです。</p>
    </div><!-- /.unit -->
  </div><!-- /.slider -->
</div><!-- /.slider-wrapper -->
  
  

</body>

</html>

/*Downloaded from https://www.codeseek.co/JunkiSuzuki/andx30abandx30ebandx30fcandx30bbandx30eb-eWdJWR */
.slider-wrapper {
  width: 320px;
  padding: 5px;
  overflow-x: auto;
  overflow-y: hidden;
  background: #CCC;
  margin: 0 auto;
}

.slider {
  width: 850px;
  -webkit-overflow-scrolling: touch;
}

.slider > * {
  -webkit-transform: translateZ(0px);
}

.slider-wrapper::-webkit-scrollbar {
  display: none;
  height: 0 !important;
}

.unit {
  float: left;
  width: 150px;
  margin: 0 0 0 5px;
  border: 1px solid #DDDDDD;
  background: #EFEFEF;
}

.unit:first-child {
  margin: 0;
}

.unit .img {
  text-align: center;
}

Comments