Nsystem
@Nsystem

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

CSSのボックスの作り方を教えてください

CSSで、写真みたいなデザインの作り方を教えてください。文字の部分は毎回変わります。
1610894304975.jpg

よろしくお願いします🙇‍♂

0

1Answer

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>
0Like

Comments

  1. @Nsystem

    Questioner

    ありがとうございます(__)
    ifの部分の長さはjsでどうにかすることにしました!

Your answer might help someone💌