Tags down


height property using % work same way as width

By : Antons Pavlovs
Date : May 04 2020, 07:55 AM

I need to set an array of text boxes using float: left in css and breaking the float at the end of each row. I want to ensure that the boxes have the same height and have been trying to use the <selector> { height: x%; } - which works well with width property, but using % does not seem to work for height without setting a specific number like <selector> { height: ypx; }.

 see example below to illustrate the issue :.

h1, p {
  font-size: 1em;
  font-weight: normal;
  border: 1px solid black;
  width: 10%;
  padding : 2%;

h1 {
  height: 40px;

p {
  height: 100%;

br {
  clear: both;
<h1> Test 1 </h1>
<h1> Test 2 </h1>
<h1> Test 3 </h1>
<h1> Test 4 </h1>
<p> Test 5</p>
<p> Test 6</p>

Resulting HTML Page

Answer :

Try using vh instead of % here, there are no parent elements here that have a defined height so % doesnt really know what to take a % of. 10vh is the same as 10% of the hieght

Share : facebook icon twitter icon
Related Posts Related Posts :
  • clear array after form submit
  • pass url variable to javascript
  • access data using api
  • div position fixed css
  • add horizontal line between two div
  • disable toggle button css
  • css fixed line height
  • background image not working
  • table cell border
  • text line break css
  • overlay div on div
  • text direction rtl css
  • javascript convert string to an object
  • bind inner div click to outer div
  • jquery ajax oncomplete
  • how to use promise in for loop
  • jquery get element using variable
  • javascript send textbox value
  • pass div class content to another class or id
  • css new line after element
  • css calc not working properly
  • link disabled jquery
  • sql join table to subquery
  • MS Access SQL Issue with OR AND Operators
  • set textarea value using php
  • php merge two arrays into one
  • php form with google captcha
  • update current row in php
  • php date format mysql
  • mysql pdo select query
  • php function return an array
  • PHP mysqldump database to sql file
  • display image query
  • php create array using foreach loop
  • associative array php
  • group_concat in mysql laravel
  • php array_push empty
  • mysql on update cascade not working
  • pdo insert prepared statement
  • mysql insert ignore vs on duplicate key
  • mysql insert into existing row
  • mysql multi insert query
  • mysql group by show all rows
  • php change profile image
  • combine multiple arrays into one array php
  • how to sum values in an array
  • how to get sum of the total time
  • How to Create Facebook live stream without notification using API ?
  • on button click make div visible
  • css affect another element on hover
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org