HTMLの書き方
head終了タグ直前に自作のCSSを読み込みます。
<link rel="stylesheet" type="text/css" href="css/7-1-46.css">
body内のボタンを表示させたい場所に以下のHTMLを記載します。
<a href="#" class="btnarrow4">7-1-46 矢印が右に移動する</a>
CSSの書き方
/*矢印が右に移動する*/
.btnarrow4{
/*矢印と下線の基点とするためrelativeを指定*/
position: relative;
/*形状*/
display: inline-block;
padding: 0 20px;
color: #333;
text-decoration: none;
outline: none;
}
/*矢印と下線の形状*/
.btnarrow4::before{
content: '';
/*絶対配置で下線の位置を決める*/
position: absolute;
bottom:-8px;
left:15%;
/*下線の形状*/
width: 85%;
height: 1px;
background:#333;
/*アニメーションの指定*/
transition: all .3s;
}
.btnarrow4::after{
content: '';
/*絶対配置で矢印の位置を決める*/
position: absolute;
bottom:-3px;
right:0;
/*矢印の形状*/
width: 15px;
height:1px;
background:#333;
transform: rotate(35deg);
/*アニメーションの指定*/
transition: all .3s;
}
/*hoverした際の移動*/
.btnarrow4:hover::before{
left:20%;
}
.btnarrow4:hover::after{
right:-5%;
}