-1

I have created the Indian flag using HTML and CSS(except the Ashok Chakra). Now I want to create the Irish flag which is just vertical tricolor rather than horizontal tricolor like in case of the Indian flag. So how do I achieve it? I have created these following codes.

body {
  background-color: yellow;
  margin-left: 40%;
  margin-right: 40%;
}

.top {
  background-color: orange;
  width: 320px;
  height: 80px;
}

.mid {
  background-color: white;
  width: 320px;
  height: 80px;
}

.botm {
  background-color: green;
  width: 320px;
  height: 80px;
}
<html>

<head>
  <link rel="stylesheet" type="text/css" href="india.css">
  <title>Flag</title>
</head>

<body>
  <div class="top"></div>
  <div class="mid"></div>
  <div class="botm"></div>
</body>

</html>
j08691
  • 204,283
  • 31
  • 260
  • 272
R.Medhi
  • 35
  • 6

5 Answers5

4

A single div with a linear-gradient or a double inset box-shadow as in the examples below could be enough


linear-gradient

.irishflag { 
        background: linear-gradient(to right, #169B62 33.33%, #fff 0, #fff 66.66%, #FF883E 0);
        width: 270px;
        height: 135px;
    }
<div class="irishflag"></div>

box-shadow

.irishflag { 
    box-shadow: 90px 0 #169B62 inset, -90px 0 #FF883E inset;
    width: 270px;
    height: 135px;
}
<div class="irishflag"></div>

Colours and proprtion are taken from wikipedia

Fabrizio Calderan
  • 120,726
  • 26
  • 164
  • 177
1

Simply add a flag container with display:flex; and reverse order. Like this:

body{
  background-color:yellow;
  margin-left:40%;    
  margin-right:40%;
}

.top{
  background-color:orange;
  width:320px;
  height:80px;
}

.mid{
  background-color:white;
  width:320px;
  height:80px;
}

.botm{
  background-color:green;
  width:320px;
  height:80px;
}

.flag{
  display: flex;
    flex-direction: row-reverse;
}
  <div class="flag">
    <div class="top"></div>
    <div class="mid"></div>
    <div class="botm"></div>
  </div>
Pedro Figueiredo
  • 2,304
  • 1
  • 11
  • 18
0

You can use flexbox to align your 'colors' in a row like this:

body{
    background-color:yellow;
    margin-left:40%;    
    margin-right:40%;
    display: flex     /* <-- Make children aligned in a row */
}

.right{
    background-color:orange;
    width:320px;
    height:80px;
}

.mid{
    background-color:white;
    width:320px;
    height:80px;
}

.left{
    background-color:green;
    width:320px;
    height:80px;
}
<body>
  <div class="left"></div>
  <div class="mid"></div>
  <div class="right"></div>
</body>
johannchopin
  • 13,720
  • 10
  • 55
  • 101
0

You can get most of the way by giving the parent div a display value of flex:

display: flex;

And then all of its direct children a flex value, indicating that the width of each should approximate one third of the width of the parent:

flex: 1 1 33%;

Working Example:

.flag {
  display: flex;
  width: 291px;
  height: 180px;
  box-shadow: 6px 6px 6px rgba(0, 0, 0, 0.2);
}

.third {
  flex: 1 1 33%;
}

.ireland .left {
  background-color: green;
}

.ireland .center {
  background-color: white;
}

.ireland .right {
  background-color: orange;
}
<div class="flag ireland">
  <div class="left third"></div>
  <div class="center third"></div>
  <div class="right third"></div>
</div>
Rounin
  • 27,134
  • 9
  • 83
  • 108
-1

FLOAT WAY:

 .top {
     background-color:
         orange;
     width: 120px;
     height: 320px;
     float: left;
 }

 .mid {
     background-color:
         white;
     width: 120px;
     height: 320px;
     float: left;
 }

 .botm {
     background-color:
         green;
     width: 120px;
     height: 320px;
     float: left;
 }

 .flag {
     overflow: hidden;
 }

HTML:

  <div class="flag">
    <div class="top"></div>
    <div class="mid"></div>
    <div class="botm"></div>
  </div>
Tommy89
  • 121
  • 1
  • 5