CSSのボックスの作り方を教えてください
0
if固定ならできた。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
* {
font-size: 24px;
font-weight: bold;
}
.oden {
margin-top: 40px;
margin-left: 100px;
}
.daikon{
position: relative;
display: inline-block;
height: 70px;
padding: 0 30px;
line-height: 70px;
border: 4px solid #f928aa;
border-radius: 10px;
}
.tikuwa{
position: absolute;
/* calc(親のheight - 自分のheight) / 2 */
top: calc((70px - 46px) / 2);
/* calc(-自分のwidth / 2 - 親のborderの幅 / 2) */
left: calc(-42px / 2 - 4px / 2);
width: 42px;
height: 46px;
border-radius: 10px;
line-height: 46px;
text-align: center;
color: white;
background-color: #f928aa;
}
</style>
</head>
<body>
<div class="oden">
<div class="daikon">
<div class="tikuwa">if</div>you can go
</div>
</div>
<div class="oden">
<div class="daikon">
<div class="tikuwa">if</div>you want to change the world, start with yourself.
</div>
</div>
</body>
</html>
@Nsystem
Questioner