I am getting output from a database. Sometimes I am getting 2 div and sometimes I am getting 3 div so I have to set the equal width of the div. I mean if there are 2 div then set 50% of each and if there are 3 div then set 33.33% of each. Would you help me in this?
#container1
{
width: 100%;
display: inline-flex;
}
#container1 div{
color: #fff;
display: inline-block;
height: 100%;
width: 50%;
background: #24252A;
text-align: center;
cursor: default;
padding: 2em 0;
}
#container1 div:nth-of-type(2) {
background: red;
}
#container1 div:nth-of-type(3)
{
width: 33.33% !important;
}
<div id="container1">
<!--div depanding upload database-->
<div></div>
<div></div>
<div></div>
</div>