Welcome to CSSBattle Challenges!
In this short article, I go through my solution for CSSBattle - #5 Acid Rain challenge. Please refer to the code snippet below to get a better insight into my thought processes and the implementation detail.
Challenge:
Solution:
<div class="container">
<div class="parent">
<div class="circle top"></div>
<div class="leaf middle"></div>
<div class="leaf bottom"></div>
</div>
</div>
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
.container {
width: 100%;
height: 100%;
background: #0B2429;
display: flex;
justify-content: center;
align-items: center;
}
.parent {
display: flex;
flex-direction: column;
transform: rotate(45deg);
}
.circle {
border-radius: 60px;
}
.leaf {
border-top-right-radius: 60px;
border-bottom-left-radius: 60px;
border-bottom-right-radius: 60px;
}
.circle, .leaf {
width: 120px;
height: 120px;
}
.top {
background: #F3AC3C;
transform: translateY(35px)
}
.middle {
background: #998235;
transform: rotate(45deg)
}
.bottom {
background: #F3AC3C;
transform: translateY(-35px) rotate(45deg)
}
</style>
Key Takeaway(s):
- using flexbox to center children elements vertically and horizontally within a parent container
As always, I welcome any feedback or questions regarding the implementation detail of the challenge. Otherwise, I hope this was useful!
Top comments (0)