Any expert please convert this button design into html css code

Hi, I am trying to convert this design of the button into code. The most difficult part is the curved side at the bottom left.

here is my code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Popular Badge</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #e0e0e0;
            margin: 0;
        }

        .badge {
            position: relative;
            display: inline-flex;
            align-items: center;
            padding: 10px 20px;
            background-color: #6C4CE7;
            color: white;
            border-radius: 20px;
            font-family: Arial, sans-serif;
            font-size: 18px;
        }

        .badge::before {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 0;
            border-left: 20px solid #5B3FC7;
            border-top: 20px solid transparent;
        }

        .icon {
            margin-right: 10px;
            font-size: 18px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="badge">
        <div class="icon">★</div>
        POPULAR
    </div>
</body>
</html>

am waiting for you reply dears.

Welcome to this forum.

Here is one approach:

4 Likes

Slightly different approach

2 Likes

I borrowed most of your code to get a one element approach :slight_smile:

<button class="badge">&#x2726 POPULAR</button>

2 Likes

Refined a little so font-size can increase and everything changes without changing other measurements.

1 Like

Well done. I started down that path but couldn’t figure out how to do the two plus signs w/o the span - the “+ +” was obviously too obvious for me :man_facepalming:

1 Like

Here is another approach (just for fun :grinning: )

1 Like

…and we have a winner :slight_smile:

(You do need background-color:transparent on the button though ;))

1 Like

I had left that out because there is a similar colour background in Post #1. Anyway, I have now updated the CodePen above. Thanks!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.