Answers for "how to make a square div element html"

CSS
3

square div

<div class='square-box'>
    <div class='square-content'>
        <h3>test</h3>
    </div>
</div>

<style>
.square-box{
    position: relative;
    width: 50%; /* You need to specify some width */
    overflow: hidden;
    background: rgba(0,0,0,0.1);
}
.square-box:before{
    content: "";
    display: block;
    padding-top: 100%;
}
.square-content{
    position:  absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    text-align: center;
    width: 100%;
}
</style>
Posted by: Guest on April-15-2022
1

how to make a square div in css

.square {
    background-color: #000;
    width: 50vw;
    height: 50vw;
}
.square h1 {
    color: #fff;
}
/* It works */
Posted by: Guest on May-26-2021

Code answers related to "how to make a square div element html"

Browse Popular Code Answers by Language