Answers for "responsive square css"

1

how to make a responsive box in css

.square {
  width: 50%;
}

.square:after {
  content: "";
  display: block;
  padding-bottom: 100%;
}
Posted by: Guest on October-23-2020
1

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>
Posted by: Guest on June-10-2021

Browse Popular Code Answers by Language