Div 100% height scroll

后端 未结 3 911
暗喜
暗喜 2020-12-30 20:14

At my page i have a navigation bar to the left that is 100% height and 25% width. It is working fine, but when there\'s scroll available, it destroys the background, and mak

相关标签:
3条回答
  • 2020-12-30 20:52

    if you want the element to take 100% of the screen use min-height: 100vh and if you want it to take 100% of the parent element use min-height: 100%

    0 讨论(0)
  • 2020-12-30 20:54

    Using min-height: 100% instead of height: 100% should fix it. See updated fiddle here: http://jsfiddle.net/zitrusfrisch/Sa6cb/3/

    0 讨论(0)
  • 2020-12-30 21:06

    I had a similar issue when I wanted to build an opaque overlay on top of a webpage. The overlay only covered the height of the browser window, not the total scrolling height of the page. I turned to Javascript to dynamically get the page height.

    $('body').append('<div style="width:100%;height:'+document.documentElement.scrollHeight+'px;background:#000000;opacity:0.5;position: absolute;top: 0;z-index: 1000;"></div>')

    0 讨论(0)
提交回复
热议问题