Monday, July 22, 2019

html - Flexbox make two divs on left and third on right




I am using flexbox to align divs, and I want to make both postavatar and userinfo in left side and posttime to be in the right.





.postheader {
display: flex;
justify-content: space-between;
}


.postheader .postavatar img {
width: 90px;
}

.postheader .userinfo {
margin-top: 10px;
margin-left: 20px;
}


.postheader .userinfo .postusername {
color: #b3b3b3;
}

.postheader .posttime {
color: #b3b3b3;
}


User Image



Fahad Aldaferi

@Q8Xbox


24 m





Answer



You can simply remove justify-content: space-between; from the flex container, and add margin-left: auto; on last flex item.






.postheader {
display: flex;
/*justify-content: space-between;*/
}

.postheader .postavatar img {
width: 90px;

}

.postheader .userinfo {
margin-top: 10px;
margin-left: 20px;
}

.postheader .userinfo .postusername {
color: #b3b3b3;
}


.postheader .posttime {
color: #b3b3b3;
margin-left: auto; /*new*/
}


User Image


Fahad Aldaferi

@Q8Xbox



24 m





No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...