Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

how to create a square element with css with dynamic width

<div class="square">
  <div class="content">
    Hello!
  </div>
</div>

.square {
  position: relative;
  width: 50%;
}

.square:after {
  content: "";
  display: block;
  padding-bottom: 100%;
}

.content {
  position: absolute;
  width: 100%;
  height: 100%;
}
 
PREVIOUS NEXT
Tagged: #create #square #element #css #dynamic #width
ADD COMMENT
Topic
Name
8+5 =