responsive square css code example
Example 1: how to make a responsive box in css
.square {
width: 50%;
}
.square:after {
content: "";
display: block;
padding-bottom: 100%;
}
Example 2: responsive square css
<!-- HTML -->
<div class='square-box'>
<div class='square-content'>
<h3>test</h3>
</div>
</div>
<!-- CSS -->
<style>
.square-box{
position: relative;
width: 50%;
overflow: hidden;
background: #4679BD;
}
.square-box:before{
content: "";
display: block;
padding-top: 100%;
}
.square-content{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
color: white;
text-align: center;
}
</style>