<div class="contents">text contents</div>
<ul class="cp_snslink01">
<li class="cp_link facebook"><a href="#"><div class="nav-label"><span>facebook Button</span></div></a></li>
<li class="cp_link twitter"><a href="#"><div class="nav-label"><span>X Button</span></div></a></li>
<li class="cp_link instagram"><a href="#"><div class="nav-label"><span>instagram Button</span></div></a></li>
</ul>
body {
/*設置する親要素ページ全体ならbodyなど*/
position: relative;
height: 100vh;
margin: 0;
padding: 0;
}
.contents {
/*サンプルはfixedの確認のためにheight指定しています。*/
height: 2000px;
}
/*SNSリンクブロックの位置設定*/
.cp_snslink01 {
position: fixed;
top: 50%;
left: 0;
transform: translateY(-50%);
margin: 0;
padding: 0;
}
/*それぞれのSNS iconの設定*/
.cp_snslink01 .cp_link {
position: relative;
display: block;
width: 40px;
height: 40px;
padding: 10px;
cursor: pointer;
}
.cp_snslink01 .cp_link::before {
position: absolute;
content: '';
background-size: contain;
background-repeat: no-repeat;
width: 40px;
height: 40px;
}
.cp_snslink01 .cp_link.facebook::before {
background-image: url(facebook_logo_secondary.svg);
}
.cp_snslink01 .cp_link.twitter::before {
background-image: url(sns/x-logo.svg);
}
.cp_snslink01 .cp_link.instagram::before {
background-image: url(instagram_glyph_white.svg);
}
/*hoverで表示されるブロックの設定*/
.cp_snslink01 .cp_link .nav-label {
position: absolute;
top: 0;
left: 60px;/*.cp_linkの幅+padding*/
display: flex;
align-items: center;
width: 150px;
height: 60px;/*.cp_linkの高さ+padding*/
padding: 0 20px;
white-space: nowrap;
}
.cp_snslink01 .cp_link a,
.cp_snslink01 .cp_link:hover {
color: #ffffff;
}
/*facebook*/
.cp_snslink01 .facebook,
.cp_snslink01 .facebook:hover,
.cp_snslink01 .facebook:hover .nav-label {
background: #0866ff;/*iconの背景とhover後の色*/
}
.cp_snslink01 .facebook .nav-label {
background: #5d9afc;/*hover時最初の色*/
}
/*twitter*/
.cp_snslink01 .twitter,
.cp_snslink01 .twitter:hover,
.cp_snslink01 .twitter:hover .nav-label {
background: #000000;/*iconの背景とhover後の色*/
}
.cp_snslink01 .twitter .nav-label {
background: #dddddd;/*hover時最初の色*/
}
/*instagram*/
.cp_snslink01 .instagram,
.cp_snslink01 .instagram:hover,
.cp_snslink01 .instagram:hover .nav-label {
background: linear-gradient(45deg, #FF7A00 0%, #FF0169 50.06%, #D300C5 99.36%);/*iconの背景とhover後の色*/
}
.cp_snslink01 .instagram .nav-label {
background: #D300C5;/*hover時最初の色*/
}
/* effect */
.cp_snslink01 .cp_link.nav-label,
.cp_snslink01 .cp_link.cp_link:hover .nav-label {
transition: transform 0.4s ease, background 0.4s ease 0.1s;
}
.cp_snslink01 .cp_link.cp_link .nav-label {
transition: transform 0.4s ease;
transform: scaleX(0);
transform-origin: left 50%;/*伸縮の基点*/
}
.cp_snslink01 .cp_link.cp_link:hover .nav-label {
transform: scaleX(1);
}