どうもですよ、はやちですよ(`⊙ω⊙´)カッ!!
ここ最近NikonのD5500と三脚を買ってしまいまして、写真を撮るのが楽しい日々を過ごしています( ˇωˇ )
これは脱インドアかな!!!✌=(´ʘ‿ʘ`)=✌
夏にはコミックマーケットがあるので、カメラの練習としてバシバシ撮っていこうと思います( ˇωˇ )
そんなことはどうでもいいですね。
今回はPHPが分からなくても簡単にWordPressでオリジナルソーシャルボタンを配置できる方法をご紹介します( ˇωˇ)☝
デザインを用意しよう
組み込む前にデザインを作っちゃいましょう( ˇωˇ)☝
HTML
組み込む前なので、まだaタグには何も入れずに用意します。
<ul class="social">
<li class="fa"><a href="#"><i class="icon-fa"></i></a></li>
<li class="ha"><a href="#"><i class="icon-ha"></i></a></li>
<li class="tw"><a href="#"><i class="icon-tw"></i></a></li>
<li class="go"><a href="#"><i class="icon-go"></i></a></li>
<li class="li"><a href="#"><i class="icon-li"></i></a></li>
</ul>
CSS
CSSはこちらです。
Webアイコン用のCSS
ソーシャルボタンのアイコンはIcoMoonでWebアイコンにしました。
はてなブックマークとLINEはないので、SVG化にしてからこちらのサイトでダウンロードしてくださいまし( ˇωˇ)☝
- IcoMoon
https://icomoon.io/
ダウンロードしたファイルにはfontのデータとソースが生成されていますので、ペペっと貼っつけておきます( ˇωˇ)☝
@font-face {
font-family: 'icomoon';
src:url('DLしたfontファイル');
src:url('DLしたfontファイル') format('embedded-opentype'),
url('DLしたfontファイル') format('truetype'),
url('DLしたfontファイル') format('woff'),
url('DLしたfontファイル') format('svg');
font-weight: normal;
font-style: normal;
}
[class^="icon-"], [class*=" icon-"]{
font-family: 'icomoon';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-fa:before {
content: "\e602";
}
.icon-go:before {
content: "\e604";
}
.icon-tw:before {
content: "\e601";
}
.icon-ha:before {
content: "\e605";
}
.icon-li:before {
content: "\e603";
}
ボタンのCSS
今回aタグの擬似要素を使ってアニメーションを作ります。
真ん中から広がるアニメーションしたくtranslateで広がる位置を指定して、opacityとwidthを0にして見えなくします( ˇωˇ)☝
liを全体的にrotateで傾けているのでwebアイコンで設定しているiタグには傾きをマイナスでつけてあげましょう( ˇωˇ)☝
.social {
text-align: center;
padding: 100px 0px 200px 0px;
}
.social li {
display: inline-block;
width: 100px;
height: 100px;
padding: 0px;
position: relative;
margin: 0px 16px;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.social li i {
-webkit-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg);
display: inline-block;
width: 40px;
height: 40px;
position: absolute;
right: 50%;
top: 50%;
margin-right: -20px;
margin-top: -20px;
}
.social li i:before {
font-size: 40px;
font-size: 4rem;
}
.social li a {
display: block;
width: 100px;
height: 100px;
border-radius: 5px;
border: 3px solid #333333;
color: #333333;
box-sizing: border-box;
position: relative;
-webkit-transform: translateZ(0);
transform: translateZ(0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transition: borderColor 0.3s;
transition: borderColor 0.3s;
}
.social li a:after {
content: "";
position: absolute;
z-index: -1;
-webkit-transition: width 0.3s, opacity 0.3s;
transition: width 0.3s, opacity 0.3s;
width: 0;
height: 105%;
top: 50%;
left: 50%;
background: #333333;
opacity: 0;
-webkit-transform: translateX(-50%) translateY(-50%);
-ms-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
border-radius: 3px;
}
hoverのCSS
hoverしたときはwidthとopacityの値をつけてあげましょう。
opacityでより滑らかな印象になります( ˇωˇ)☝
.social li a:hover:after {
width: 100%;
opacity: 1;
}
.social li a:hover i:before {
color: #fff;
}
/*facebookアイコン調整*/
.icon-fa {
margin-top: -21px !important;
margin-right: -11px !important;
}
.icon-fa:before {
font-size: 5rem !important;
}
ボタンの色
それぞれソーシャルボタンの色を設定しておきます( ˇωˇ)☝
/*facebook*/
.fa a:after {
background: #3b5998 !important;
}
.fa a:hover {
border-color: #3b5998 !important;
}
/*hatena*/
.ha a:after {
background: #2C6EBD !important;
}
.ha a:hover {
border-color: #2C6EBD !important;
}
/*twitter*/
.tw a:after {
background: #00aced !important;
}
.tw a:hover {
border-color: #00aced !important;
}
/*google*/
.go a:after {
background: #dd4b39 !important;
}
.go a:hover {
border-color: #dd4b39 !important;
}
/*line*/
.li a:after {
background: #1EC221 !important;
}
.li a:hover {
border-color: #1EC221 !important;
}
できあがったのはこちらになります( ˘ω˘)☞三☞シュッシュッ
LIGはWebサイト制作を支援しています。ご興味のある方は事業ぺージをぜひご覧ください。