0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CSSで吹き出し 作成方法

Last updated at Posted at 2021-06-11

CSSで吹き出しを作る

LPなどで吹き出しを付けたいときのために、簡単に作成する方法をご紹介致します。

まずは、吹き出しの中身を下記のように作成致します。

スクリーンショット 2021-06-06 15.13.43.png


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="fukidashi-block">
        <p class="sentence">吹き出し</p>
    </div>
</body>
</html>

<style>
    .fukidashi-block {
        text-align: center;
        background-color: green;
        padding: 10px 16px;
        position: relative;
        border-radius: 10px;
        color: white;
        font-weight: 700;
    }
   
</style>

次に、吹き出しで一番難しく感じる三角形部分。cssにコードを追加します。
これで完成です。

スクリーンショット 2021-06-06 15.18.37.png

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="fukidashi-block">
        <p class="sentence">吹き出し</p>
    </div>
</body>
</html>


<style>
    
    /* 追加 */
    .sentence::before {
        position: absolute;
        content: "";
        border: 9px solid transparent;
        border-top: 11px solid green;
        bottom: -40%;
        left: 50%;
        transform: translateY(-50%) translateX(-50%);
    }
    /* ここまで */

    .fukidashi-block {
        text-align: center;
        background-color: green;
        padding: 10px 16px;
        position: relative;
        border-radius: 10px;
        color: white;
        font-weight: 700;
    }
   
</style>

以上になります。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?