cssを使って三角形を作り、その中央に文字を配置したいです。
css
1 2.triangle{ 3 border-top: 86.6025px solid #F0897F; 4 border-right: 50px solid transparent; 5 border-left: 50px solid transparent; 6 color: black; 7 list-style: none; 8 text-align: center; 9 line-height: 60px; 10 opacity: 0.6; 11 position: absolute; 12 top:0px; 13 right:0px; 14 left:0px; 15 bottom:0px; 16 margin:auto; 17 width:0; 18 height:0; 19} 20p{ 21 text-align: center; 22} 23
HTML
1<!DOCTYPE html> 2<html lang="en" dir="ltr"> 3 <head> 4 <link rel="stylesheet" href="style.css"> 5 <meta charset="utf-8"> 6 <title></title> 7 </head> 8 <body> 9 <div class="triangle"> 10 <p>top</p> 11 </div> 12 </body> 13</html> 14
今はこの状態です。
これをchromeで開くと三角形の外に文字が来てしまいます。
回答よろしくお願いします。
中央寄せっていうより、CSSで書いた三角形の上に文字"top"を乗せるってことでは?
回答1件
あなたの回答
tips
プレビュー