using percent

suggest change

Percentages are useful units when creating a responsive layout.

A percentage width is resolved against the containing block's width.

Equation:

(parent container's width) * (percentage) = output

For Example:

Parent has 100px width while the Child has 50%.

On the output, the Child’s width will be half(50%) of the Parent’s, which is 50px.

HTML

<div class="parent">
   PARENT
   <div class="child">
     CHILD
   </div>
</div>

CSS

*{
  color: #CCC;
}

.parent{
  background-color: blue;
  width: 100px;
}

.child{
  background-color: green;
  width: 50%;
}

OUTPUT

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents