0

I am trying to recreate Ethopia flag using HTML and CSS but I am unable to do the middle part of the flag. The star inside the circle is not coming as expected. HTML and CSS I have applied:

body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
}

.flag {
    width: 450px;
    height: 300px;
    position: relative;
    /* Green, Yellow, Red stripes using linear gradient */
    background: linear-gradient(
        to bottom,
        #078900 0%,     /* Green */
        #078900 33.33%,
        #fddc12 33.33%,   /* Yellow */
        #fddc12 66.66%,
        #e4032d 66.66%,   /* Red */
        #e4032d 100%
    );
    border: 1px solid #333;
}

.emblem {
    /* Position and size of the emblem container */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40%; 
    height: 40%;
}

/* Ensures the SVG scales correctly within the .emblem container */
.emblem svg {
    width: 100%;
    height: 100%;
    display: block;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Accurate Ethiopian Flag</title>
</head>
<body>
    <div class="flag">
        <div class="emblem">
            <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
                <circle cx="50" cy="50" r="48" fill="#03459c"/>

                <g fill="#fddc12">
                    <rect x="49" y="5" width="2" height="90" transform="rotate(0 50 50)"/>
                    <rect x="49" y="5" width="2" height="90" transform="rotate(45 50 50)"/>
                    <rect x="49" y="5" width="2" height="90" transform="rotate(90 50 50)"/>
                    <rect x="49" y="5" width="2" height="90" transform="rotate(135 50 50)"/>
                </g>

                <polygon 
                    points="50,25 56.6,43.3 75,43.3 59.2,54 65.8,72.3 50,61.6 34.2,72.3 40.8,54 25,43.3 43.4,43.3" 
                    fill="#fddc12"
                />

                <polygon 
                    points="50,25 56.6,43.3 75,43.3 59.2,54 65.8,72.3 50,61.6 34.2,72.3 40.8,54 25,43.3 43.4,43.3" 
                    fill="none" 
                    stroke="#fddc12" 
                    stroke-width="1.5"
                />
            </svg>
            </div>
    </div>
</body>
</html>

My output:

enter image description here

Expected output:

enter image description here

New contributor
Anitha Kode is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
9
  • I was almost going to say, "ASK GPT", but it produces a worse result than you currently have (i.sstatic.net/4t05jpLj.png). (Chatgpt was converting this SVG). Option that remains is investigate more time in learning CSS, or use this SVG (which seems a quicker option...) Commented 20 hours ago
  • 2
    This is less and HTML/CSS problem than it is an SVG issue, as the SVG you are using closes the star and fills it in. Commented 20 hours ago
  • @Heretic Monkey — Correct. That star should be composed of at least 5 separate paths. Alternatively, it can be composed as a start with some background-colored mask paths on top of it. It will make the solution. Commented 20 hours ago
  • Please see two comments above. They will make a solution. Additionally, 5 rays should be corrected. They are longer and should be made separate. Commented 20 hours ago
  • 1
    Are you wanting to do this without SVG (i.e. is it an exercise in pure CSS/HTML) - if not then is the SVG linked by @Luuk sufficient? Commented 20 hours ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.