Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
166 views
in Technique[技术] by (71.8m points)

html - Sizing main viewport for firefox mobile

I've been looking for a way to size the main viewport in mobile to accommodate for the navigation bar at the bottom of the page. I want all the content to be visible in between the top of the page and the top of the navigation bar (CSS3 100vh not constant in mobile browser)

This code works for me in all desktop browsers, and all mobile browsers except for firefox

      html,
      body {
        height: 100%;
      }
      #hero {
        height: calc(100vh - calc(100vh - 100%));
        background-color: aqua;
      }

How come I'm getting different behaviour in firefox mobile? Thanks for looking

question from:https://stackoverflow.com/questions/65833892/sizing-main-viewport-for-firefox-mobile

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

while awaiting for clarification, here is a sample/template that could do what you look for via grid (it could be flex if you feel more confident with it).

html,
body,
body > div {
  height: 100%;
  margin: 0;
}
body > div {
  display: grid;
  grid-template-rows: 1fr auto;
}
nav {
  background: blue;
  padding: 1em;
  order: 1;
}
main {
  overflow: auto;
}
<div>
  <nav>At the bottom , of any height.</nav>
  <main> let me scroll if too <br><br><br><br><br><br><br><br>...<br><br><br><br><br><br><br>....<br><br><br><br><br><br><br><br>....<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>....<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>....<br><br><br><br><br><br><br><br><br><br>....short</main>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...