[パーツ]アコーディオンスライド レスポンシブでタイトルが縦になるスライド

CSS HTML
 2018.05.07
 2018.05.24

レスポンシブでタイトルが縦になるスライド

ウィンドウ幅768px以下でclass「.slidecont」に設定された「title属性」を使用してタイトルを縦に表示しています。

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_accordionslide07">
<div class="slideitem">
<h2>タイトル 1</h2>
<div class="slidecont" title="タイトル 1">
<div class="text">
<p>テキスト1</p>
</div>
</div>
</div>
<div class="slideitem">
<h2>タイトル 2</h2>
<div class="slidecont" title="タイトル 2">
<div class="text">
<p>テキスト2</p>
</div>
</div>
</div>
<div class="slideitem">
<h2>タイトル 3</h2>
<div class="slidecont" title="タイトル 3">
<div class="text">
<p>テキスト3</p>
</div>
</div>
</div>
<div class="slideitem">
<h2>タイトル 4</h2>
<div class="slidecont" title="タイトル 4">
<div class="text">
<p>テキスト4</p>
</div>
</div>
</div>
<div class="slideitem">
<h2>タイトル 5</h2>
<div class="slidecont" title="タイトル 5">
<div class="text">
<p>テキスト5</p>
</div>
</div>
</div>
</div>
.cp_accordionslide07 {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
visibility: hidden;
width: 100%;
height: 80vh;
}
.cp_accordionslide07 .slideitem {
position: relative;
visibility: visible;
overflow: hidden;
width: 20%;
height: 100%;
cursor: pointer;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
-webkit-transition-delay: 0s;
transition-delay: 0s;
-webkit-transition-timing-function: linear;
transition-timing-function: linear;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-property: all;
transition-property: all;
color: #ffffff;
}
.cp_accordionslide07 .slideitem:nth-child(1) {
background-image: url("https://copypet.jp/contents/wp-content/uploads/sample11.jpg");
}
.cp_accordionslide07 .slideitem:nth-child(2) {
background-image: url("https://copypet.jp/contents/wp-content/uploads/sample12.jpg");
}
.cp_accordionslide07 .slideitem:nth-child(3) {
background-image: url("https://copypet.jp/contents/wp-content/uploads/sample13.jpg");
}
.cp_accordionslide07 .slideitem:nth-child(4) {
background-image: url("https://copypet.jp/contents/wp-content/uploads/sample14.jpg");
}
.cp_accordionslide07 .slideitem:nth-child(5) {
background-image: url("https://copypet.jp/contents/wp-content/uploads/sample15.jpg");
}
.cp_accordionslide07 .slideitem:after {
position: absolute;
z-index: 2;
top: 0;
left: 0;
display: block;
width: 100%;
height: 100%;
content: '';
}
.cp_accordionslide07:hover .slideitem:hover {
width: 60%;
-ms-flex-negative: 0;
flex-shrink: 0;
}
.cp_accordionslide07 .slideitem .slidecont {
position: absolute;
z-index: 4;
top: 0px;
left: 30px;
visibility: hidden;
max-width: 400px;
padding: 20px;
-webkit-transition: opacity 0.2s ease 0;
transition: opacity 0.2s ease 0;
opacity: 0;
}
.cp_accordionslide07 .slideitem:hover .slidecont {
-webkit-transition: opacity 0.3s ease 0.3s;
transition: opacity 0.3s ease 0.3s;
opacity: 1;
}
.cp_accordionslide07 .slideitem h2 {
font-size: 1.2em;
position: absolute;
bottom: 10px;
left: 50%;
margin: 0;
padding: 0;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
white-space: nowrap;
}
.cp_accordionslide07:hover .slideitem:hover .slidecont {
visibility: visible;
}
@media only screen and (max-width:768px) {
.cp_accordionslide07 .slideitem .slidecont {
position: relative;
right: 0px;
left: 0px;
visibility: visible;
opacity: 1;
min-height: 75vh;
}
.cp_accordionslide07 .slideitem .slidecont .text {
visibility: hidden;
opacity: 0;
-webkit-transition: opacity 0.3s ease 0.3s;
transition: opacity 0.3s ease 0.3s;
}
.cp_accordionslide07 .slideitem:hover .slidecont .text {
visibility: visible;
opacity: 1;
margin-top: 40px;
}
.cp_accordionslide07 .slideitem h2 {
visibility:hidden;
}
.cp_accordionslide07 .slideitem:hover  h2 {
visibility: visible;
top: 20px;
left: 65px;
}
.cp_accordionslide07 .slideitem .slidecont::before {
position: absolute;
font-size: 1.2em;
font-weight: bold;
display: block;
text-align: center;
top: 50%;
left: 25%;
width: 12em;
content: attr(title);
-webkit-transform: rotate(-90deg) translateX(-50%);
transform: rotate(-90deg) translateX(-50%);
-webkit-transform-origin: 0 0 0;
transform-origin: 0 0 0;
visibility: visible;
opacity: 1;
}
.cp_accordionslide07 .slideitem:hover .slidecont::before {
visibility:hidden;
opacity: 0;
}
}

copypet.jp

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

More Info

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