[パーツ]アコーディオンスライド レスポンシブで縦に開くスライド

CSS HTML
 2018.05.07

レスポンシブで縦に開くスライド

ウィンドウ幅768px以下で横にスライドしていたものが縦にスライドします。

browser:  65 11 20 11 
ニャン易度 

Section 1

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Section 2

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Section 3

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Section 4

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Section 5

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

<div class="cp_accordionslide08">
<div class="slideitem">
<h2>タイトル 1</h2>
<div class="slidecont">
<p>テキスト 1</p>
</div>
</div>
<div class="slideitem">
<h2>タイトル 2</h2>
<div class="slidecont">
<p>テキスト 2</p>
</div>
</div>
<div class="slideitem">
<h2>タイトル 3</h2>
<div class="slidecont">
<p>テキスト 3</p>
</div>
</div>
<div class="slideitem">
<h2>タイトル 4</h2>
<div class="slidecont">
<p>テキスト 4</p>
</div>
</div>
<div class="slideitem">
<h2>タイトル 5</h2>
<div class="slidecont">
<p>テキスト 5</p>
</div>
</div>
</div>
.cp_accordionslide08 {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
background-color: #031625;
}
.cp_accordionslide08:hover .slideitem {
width: 20%;
}
.cp_accordionslide08 .slideitem {
position: relative;
overflow: hidden;
width: 20%;
height: 60vh;
-webkit-transition: width 0.5s ease;
transition: width 0.5s ease;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
color: #ffffff;
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.cp_accordionslide08 .slideitem:nth-child(1) {
background-image: url('img/sample6.jpg');
}
.cp_accordionslide08 .slideitem:nth-child(2) {
background-image: url('img/sample8.jpg');
}
.cp_accordionslide08 .slideitem:nth-child(3) {
background-image: url('img/sample10.jpg');
}
.cp_accordionslide08 .slideitem:nth-child(4) {
background-image: url('img/sample12.jpg');
}
.cp_accordionslide08 .slideitem:nth-child(5) {
background-image: url('img/sample14.jpg');
}
.cp_accordionslide08 .slideitem:before,
.cp_accordionslide08 .slideitem:after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
content: '';
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.cp_accordionslide08 .slideitem:after {
-webkit-transition: opacity 0.5s ease;
transition: opacity 0.5s ease;
opacity: 1;
background: rgba(3, 22, 37, 0.85);
}
.cp_accordionslide08 .slideitem:before {
z-index: 1;
-webkit-transition: opacity 0.5s ease, -webkit-transform 0.5s ease;
transition: opacity 0.5s ease, -webkit-transform 0.5s ease;
transition: opacity 0.5s ease, transform 0.5s ease;
transition: opacity 0.5s ease, transform 0.5s ease, -webkit-transform 0.5s ease;
-webkit-transform: translate3d(0, 0, 0) translateY(50%);
transform: translate3d(0, 0, 0) translateY(50%);
opacity: 0;
background: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), color-stop(75%, #000000));
background: -webkit-linear-gradient(top, rgba(0, 0, 0, 0) 0%, #000000 75%);
background:         linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, #000000 75%);
}
.cp_accordionslide08 .slideitem:hover {
width: 60% !important;
}
.cp_accordionslide08 .slideitem:hover:after {
opacity: 0;
}
.cp_accordionslide08 .slideitem:hover:before {
-webkit-transition: opacity 1s ease, -webkit-transform 1s ease 0.25s;
transition: opacity 1s ease, -webkit-transform 1s ease 0.25s;
transition: opacity 1s ease, transform 1s ease 0.25s;
transition: opacity 1s ease, transform 1s ease 0.25s, -webkit-transform 1s ease 0.25s;
-webkit-transform: translate3d(0, 0, 0) translateY(0);
transform: translate3d(0, 0, 0) translateY(0);
opacity: 1;
}
.cp_accordionslide08 .slideitem:hover .slidecont {
-webkit-transition: all 0.75s ease 0.5s;
transition: all 0.75s ease 0.5s;
-webkit-transform: translateY(0);
transform: translateY(0);
opacity: 1;
}
.cp_accordionslide08 .slideitem h2 {
font-size: 1.4em;
position: absolute;
z-index: 1;
top: 50%;
left: 50%;
-webkit-transition: all 0.75s ease;
transition: all 0.75s ease;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
white-space: nowrap;
}
.cp_accordionslide08 .slideitem h2::before {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
content: '';
}
.cp_accordionslide08 .slideitem:hover h2 {
top: 2%;
}
.cp_accordionslide08 .slidecont {
position: relative;
z-index: 1;
top: 10%;
margin: 0 1.618em;
-webkit-transform: translate3d(0, 0, 0) translateY(25px);
transform: translate3d(0, 0, 0) translateY(25px);
text-align: center;
opacity: 0;
}
@media only screen and (max-width:768px) {
.cp_accordionslide08 {
display: block;
}
.cp_accordionslide08:hover .slideitem {
width: 100%;
height: 20vh;
}
.cp_accordionslide08 .slideitem {
width: 100%;
height: 20vh;
}
.cp_accordionslide08 .slideitem:hover {
width: 100% !important;
height: 100vh !important;
}
.cp_accordionslide08 .slideitem h2 {
top: 35%;
}
}

copypet.jp

CSS3などで新たに追加された要素・装飾方法など、日々コードを書いていないと忘れてしまったり、ささっとプロトタイプを作る時などちょっとしたことに時間をかけている暇はない。そんな時に「あ〜、あれストックしときゃよかったなぁ」って困った自分用のストックブログです。カスタマイズなどがしやすいよう、昨今のweb制作に取り入れられる一般的なコードを中心に掲載しています。

More Info

こんな記事はいかがですか?