Bootstrap fullscreen layout with 100% height

后端 未结 3 979
感动是毒
感动是毒 2020-12-23 16:45

I want to develop a kiosk-app which should stretch itself to 100% of the complete touch-screen.

When I\'m nesting for each application-view/template the rows and co

相关标签:
3条回答
  • 2020-12-23 17:13

    Here's an answer using the latest Bootstrap 4.0.0. This layout is easier using the flexbox and sizing utility classes that are all provided in Bootstrap 4. This layout is possible with very little extra CSS.

    #mmenu_screen > .row {
        min-height: 100vh;
    }
    
    .flex-fill {
        flex:1 1 auto;
    }
    
    <div id="mmenu_screen" class="container-fluid main_container d-flex">
        <div class="row flex-fill">
            <div class="col-sm-6 h-100">
                <div class="row h-50">
                    <div class="col-sm-12" id="mmenu_screen--book">
                        <!-- Button for booking -->
                        Booking
                    </div>
                </div>
                <div class="row h-50">
                    <div class="col-sm-12" id="mmenu_screen--information">
                        <!-- Button for information -->
                        Info
                    </div>
                </div>
            </div>
            <div class="col-sm-6 mmenu_screen--direktaction flex-fill">
                <!-- Button for direktaction -->
                Action
            </div>
        </div>
    </div>
    

    Demo

    The flex-fill and vh-100 classes are included in Bootstrap 4.1 (and later)

    0 讨论(0)
  • 2020-12-23 17:14

    If there is no vertical scrolling then you can use position:absolute and height:100% declared on html and body elements.

    Another option is to use viewport height units, see Make div 100% height of browser window

    Absolute position Example:

    html, body {
    height:100%;
    position: absolute;
    background-color:red;
    }
    .button{
      height:50%;
      background-color:white;
    }
    <div class="button">BUTTON</div>

    html, body {min-height:100vh;background:gray;
    }
    .col-100vh {
      height:100vh;
      }
    .col-50vh {
      height:50vh;
      }
    #mmenu_screen--information{
      background:teal;
    }
    #mmenu_screen--book{
       background:blue;
    }
    .mmenu_screen--direktaction{
      background:red;
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <div id="mmenu_screen" class="col-100vh container-fluid main_container">
    
        <div class="row col-100vh">
            <div class="col-xs-6 col-100vh">
                
                    <div class="col-50vh col-xs-12" id="mmenu_screen--book">
                        BOOKING BUTTON
                    </div>
               
                    <div class="col-50vh col-xs-12" id="mmenu_screen--information">
                        INFO BUTTON
                    </div>
                
            </div>
            <div class="col-100vh col-xs-6 mmenu_screen--direktaction">
               DIRECT ACTION BUTTON
            </div>
        </div>
    
    </div>

    0 讨论(0)
  • 2020-12-23 17:19

    All you have to do is have a height of 100vh on your main container/wrapper, and then set height 100% or 50% for child elements.. depending on what you're trying to achieve. I tried to copy your mock up in a basic sense.

    In case you want to center stuff within, look into flexbox. I put in an example for you.

    You can view it on full screen, and resize the browser and see how it works. The layout stays the same.

    .left {
      background: grey;  
    }
    
    .right {
      background: black;  
    }
    
    .main-wrapper {
      height: 100vh;  
    }
    
    .section {
      height: 100%;  
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }
    
    .half {
      background: #f9f9f9;
      height: 50%;  
      width: 100%;
      margin: 15px 0;
    }
    
    h4 {
      color: white;  
    }
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    
    <div class="main-wrapper">
      <div class="section left col-xs-3">
        <div class="half"><h4>Top left</h4></div>
        <div class="half"><h4>Bottom left</h4></div>
      </div>
      <div class="section right col-xs-9">
        <h4>Extra step: center stuff here</h4>
      </div>
    </div>

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