1

example: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_img_height I can change the width in terms of % or px but, I can only change the height in terms of px and not % (you can experiment by changing height to a % and seeing it does not change). This is just an example but I am wondering how you change height in terms of %? Thank you.

Luke Weaver
  • 43
  • 2
  • 6

2 Answers2

0

it is working just fine. just edit like width="200%"

img src="smiley.gif" alt="Smiley face" width="200%" height="400%"

see height="400%"

johnguild
  • 435
  • 1
  • 5
  • 25
0

If you want to use percentage height in a div, the parent objects of it have to have explicit height property. Unlike width, website with fixed heights will bring you problems.

My advice: don't use percentage height in HTML. Instead, try padding

#mydiv{
   padding-bottom: 20%;
}

See here for more info.

Community
  • 1
  • 1
FlySoFast
  • 1,854
  • 6
  • 26
  • 47
  • yeah, the 'See here for more info' did help for sure. The div will give its height bounds and then I can set the height to a % of those bounds.
    Smiley face
    – Luke Weaver Jun 03 '15 at 00:49
  • Even then it does not scale properly, but I guess there is nothing that can be done. edit: not sure how adding adding padding on the bottom helps – Luke Weaver Jun 03 '15 at 00:52
  • edit: #mydiv { height:50vh; background:red; width:50%; } works – Luke Weaver Jun 03 '15 at 00:59