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を色々と変えて試してみてください。
2026/12/01
AI
Claude Code
2026/11/30
Wordpress
2026/11/28
神社
2026/11/27
Claude Code
AI
Wordpress
ブログのURL(スラッグ)は英語にする?AIにタイトルを英訳させて決めた5つのルールと、昔のURLに残っていた7つのスペルミス
2026/11/26
Wordpress
プラグイン
ホームページ制作