CSS: height- fill out rest of div?

前端 未结 7 1976
星月不相逢
星月不相逢 2020-12-10 10:13

i wonder if this is possible with simple css or if i have to use javascript for this?

i have a sidebar on my website. a simple div#sidbar it\'s normally about 1024px

7条回答
  •  萌比男神i
    2020-12-10 10:56

    I came across this question while looking for an answer to a similar question, and I thought I'd illustrate calc. As of this post, calc is not yet supported cross-browser; however, you can check this link here to see if your target browsers are supported. I've modified matt's hypothetical case to use calc in an example on jsFiddle. Essentially it is a pure CSS solution that does what casablanca proposes in his answer. For example, if a browser supports calc, then height: calc(100% - 200px); would be valid as well as for similar properties.

提交回复
热议问题