2016/02/01
css
備忘録です。
下記のサンプルのように枠の下に三角を表示するCSSです。
サンプル1のhtml
<div class="sampleBox1">テキスト</div>
サンプル1のCSS
.sampleBox1{
width:100px;
height:auto;
padding:10px 0;
position:relative;
border:1px solid #0000ff;
text-align:center;
}
.sampleBox1:before{
position:absolute;
width:0;
height:0;
border-color:#00f transparent transparent;/*下に三角*/
border-width:10px;
border-style:solid;
bottom:-20px;
left:40%;
content: " ";
}
【応用編】カーソルを合わせると三角表示
サンプル2のhtml
<div class="sampleBox2">テキスト</div>
サンプル2のCSS
.sampleBox2{
display:block;
width:100px;
height:auto;
padding:10px 0;
position:relative;
border:1px solid #0000ff;
text-align:center;
cursor:pointer;
}
.sampleBox2:hover:before{
position:absolute;
width:0;
height:0;
border-color:#00f transparent transparent;/*下に三角*/
border-width:10px;
border-style:solid;
bottom:-20px;
left:40%;
content: " ";
}
【応用編】枠の右に三角表示
サンプル3のhtml
<div class="sampleBox3">テキスト</div>
サンプル3のCSS
.sampleBox3{
width:100px;
height:auto;
padding:10px 0;
position:relative;
border:1px solid #0000ff;
text-align:center;
}
.sampleBox3:hover:before{
position:absolute;
width:0;
height:0;
border-color:transparent transparent transparent #00f;/*右に三角*/
border-width:10px;
border-style:solid;
top:30%;
right:-20px;
content: " ";
}
cssを色々と変えて試してみてください。
ゼヒトモ内でのプロフィール: ROCKSTREAM, ゼヒトモのホームページ作成・制作サービス, 仕事をお願いしたい依頼者と様々な「プロ」をつなぐサービス
2025/01/31
JQuery
2025/01/01
神社
御朱印
相模原
2024/10/27
ブラウザ
カスタム投稿
Wordpress
2024/08/20
神社
御朱印
2024/07/06
神社
御朱印