Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="carousel">
  <!-- スライドのリスト -->
  <div class="contains">
    <!-- スライドを選択するためのラジオボタンリスト。 -->
    <!-- 数は増減しても構わないです。 最初は1番目を選択状態(checked)にします。-->
    <!-- Slide各ラジオボタンに個別のidを定義して、nameはすべて同じ値にします。 -->
    <input class="slide_select" type="radio" id="SlideA" name="slide_check" checked />
    <input class="slide_select" type="radio" id="SlideB" name="slide_check" />
    <input class="slide_select" type="radio" id="SlideC" name="slide_check" />
    <input class="slide_select" type="radio" id="SlideD" name="slide_check" />
    <!-- スライド -->
    <!-- 上のラジオボックスと同じ数だけ記述します。-->
    <div class="slide">
      <!-- スライドの前へ、次へとスクロールさせるボタン -->
      <div class="scroll_controler">
        <!-- 前へボタン forで戻る先のラジオボタンのidを書きます。-->
        <!-- 先頭要素なので、最後のスライドのidである"SlideD"を書いています。 -->
        <label class="scroll_button scroll_prev" for="SlideD"></label>
        <!-- 次へボタン 上と同様にforで進む先のラジオボタンのidを書きます。-->
        <!-- 進み先は2番目の要素なので、2番目のスライドのid"SlideB"を書いています。 -->
        <label class="scroll_button scroll_next" for="SlideB"></label>
      </div>
      <!-- スライドの内容(ここでは画像)を記述します。 -->
      <!-- div要素に変えれば文字を加えることもできます。 -->
      <img src="https://picsum.photos/320/180?random=1">
    </div>
    <!-- スライド(2番目)内容は1個めと同じ -->
    <div class="slide">
      <div class="controler_scroll">
        <label class="scroll_button scroll_prev" for="SlideA"></label>
        <label class="scroll_button scroll_next" for="SlideC"></label>
      </div>
      <img src="https://picsum.photos/320/180?random=2">
    </div>
    <!-- スライド(3番目)内容は1個めと同じ -->
    <div class="slide">
      <div class="controler_scroll">
        <label class="scroll_button scroll_prev" for="SlideB"></label>
        <label class="scroll_button scroll_next" for="SlideD"></label>
      </div>
      <img src="https://picsum.photos/320/180?random=3">
    </div>
    <!-- スライド(4番目)内容は1個めと同じ -->
    <div class="slide">
      <div class="controler_scroll">
        <label class="scroll_button scroll_prev" for="SlideC"></label>
        <label class="scroll_button scroll_next" for="SlideA"></label>
      </div>
      <img src="https://picsum.photos/320/180?random=4">
    </div>
    <!-- スライド移動用ボタン -->
    <div class="move_controler">
      <!-- 1個目のスライドのボタン -->
      <!-- 一番上のラジオボタンの1個目のスライドのid”A”をforに定義します-->
      <label class="button_move" for="SlideA"></label>
      <label class="button_move" for="SlideB"></label>
      <label class="button_move" for="SlideC"></label>
      <label class="button_move" for="SlideD"></label>
    </div>
  </div>
</div>
              
            
!

CSS

              
                /* カルーセル全体 */
.carousel {
  /* 水平方向中央寄せ */
  display: flex;
  justify-content: center;
}
/* カルーセル内容 */
.contains {
  /* サイズは自由に変更してください。*/
  /* 下の.slideも同じサイズにしてください。 */
  width: 320px;
  height: 180px;
  overflow: hidden;
  position: relative;
  padding: 0;
  list-style: none;
}
/* スライド切り換え用ラジオボタンは常に非表示 */
.slide_select {
  display: none;
}
/* 各スライド */
.slide {
  /* サイズは自由に変更してください。*/
  /* 上の.containsも同じサイズにしてください。 */
  width: 320px;
  height: 180px;
  position: absolute;
  /* スライドの初期値は選択されていないので透明にしておく */
  opacity: 0;
}
/* 前へ次へボタン */
.scroll_button {
  position: absolute;
  display: block;
  height: 30px;
  width: 30px;
  /* 縦中央から20px上の位置 */
  top: 50%;
  margin-top: -20px;
/* 上辺と右辺のみ幅5pxの枠線 */
  border-width: 5px 5px 0 0;
  border-style: solid;
  border-color: #fdfdfd;
  cursor: pointer;
  /* 普段はボタンはやや薄くする */
  opacity: 0.5;
  /* スライドよりも前面にする */
  z-index: 3;
}
/* ホバー時にボタンを強調 */
.scroll_button:hover {
  opacity: 1;
}
/* 前へボタン */
.scroll_prev {
  left: 15px;
  /* 上辺と右辺の枠線を回転して"<"にする */
  transform: rotate(-135deg);
}
/* 次へボタン */
.scroll_next {
  right: 15px;
  /* 上辺と右辺の枠線を回転して">"にする */
  transform: rotate(45deg);
}
/* スライド移動ボタンエリア */
.move_controler {
  position: absolute;
  bottom: 20px;
  width: 100%;
  text-align: center;
}
/* スライド移動の各ボタン */
.button_move {
  display: inline-block;
  height: 15px;
  width: 15px;
  margin: 0 2px;
  border-radius: 100%;
  cursor: pointer;
  /* 普段はやや薄くする */
  opacity: 0.5;
  /* スライドより前面にする */
  z-index: 2;
}
/* ホバー時はやや明るくする */
.button_move:hover {
  opacity: 0.75;
}
/* スライド移動ボタンの色 */
.button_move {
  background-color: #fdfdfd;
}
/* 1番目のスライド選択時 */
/* 1番目のスライドの透明度を0にして表示する */
.slide_select:nth-of-type(1):checked ~ .slide:nth-of-type(1) {
  opacity: 1;
}
/* 1番目のスライドの前へ次へボタンの領域を */
.slide_select:nth-of-type(1):checked
  ~ .move_controler
  .button_move:nth-of-type(1) {
  opacity: 1;
}
.slide_select:nth-of-type(2):checked ~ .slide:nth-of-type(2) {
  opacity: 1;
}
.slide_select:nth-of-type(2):checked
  ~ .move_controler
  .button_move:nth-of-type(2) {
  opacity: 1;
}
.slide_select:nth-of-type(3):checked ~ .slide:nth-of-type(3) {
  opacity: 1;
}
.slide_select:nth-of-type(3):checked
  ~ .move_controler
  .button_move:nth-of-type(3) {
  opacity: 1;
}
.slide_select:nth-of-type(4):checked ~ .slide:nth-of-type(4) {
  opacity: 1;
}
.slide_select:nth-of-type(4):checked
  ~ .move_controler
  .button_move:nth-of-type(4) {
  opacity: 1;
}
              
            
!

JS

              
                
              
            
!
999px

Console