CSS expression to set height of div

后端 未结 2 747
轮回少年
轮回少年 2020-12-04 02:43

I want to set the height of a div based on CSS expression.

Basically it should be set as some % (say 90%) of the viewport width I tried the follow

2条回答
  •  感情败类
    2020-12-04 03:12

    You're combining CSS and javascript, which will not work.

    You either want to just set height:90%; (which will do 90% of the width of the parent element, not the page - unless the div is at the root of the page).

    Otherwise you should create a javascript block (preferably as part of an onload script), e.g... (not tested)

    
    

    Edit - Thanks @Chris for pointing out that the questioner was asking for the height to be set, not the width.

    I think javascript is your only way of doing this...

    
    

提交回复
热议问题