Reputation: 3333
I would like to set height for div element in the form of percentage. not by pixel wise.
$("#div1").height("200px");
so how should I set this in percentage wise?
Upvotes: 2
Views: 68
Reputation: 29166
$("#div1").css("height", "20%");
sets the height to 20%
of the element with id div1
Upvotes: 4
Reputation: 1242
you might need to set your body
and html
tag to 100%.
//css
html, body {
height: 100%;
}
then just change the px
to %
$("#div1").height("20%");
Upvotes: 3