Padheye.com : Discover Excellence

The Path To Discover Excellence.

Thursday, 18 February 2016

Usage of Percentages in CSS

 

Usage of Percentages in CSS

Instead of defining a fixed width using units like px, or cm, percentages can be used in CSS to set the height and width of child elements relative to the dimensions of their parent. The child elements will grow or shrink according to the set percentage values if the parent element changes in size.


.news-row {
  height: 300px;
  width: 500px;
}

.news-row .news-column {
  height: 80%; /* 240px */
  width: 50%; /* 250px */
}

No comments:

Post a comment