div 100% height - CSS

Asked

Viewed 1,226 times

0

how can I leave my column 100% height?

example:

EXAMPLE

where it is written Teste, is the column q has to stand 100% height,

DETAIL

on some screens, I will add content using jQuery, also need to not let this content that is not visible yet out of height

CODE

    <div class="col-xs-12 col-md-12" id="menu">
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Brand</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                  <li><a href="index.html"><span class="glyphicon glyphicon-envelope"></span> Item</a></li>
                  <li><a href="index.html"><span class="glyphicon glyphicon-shopping-cart"></span> Item</a></li>
                  <li><a href="index.html"><span class="glyphicon glyphicon-list"></span> Item</a></li>
                  <li><a href="index.html"><span class="glyphicon glyphicon-signal"></span> Item</a></li>
                  <li><a href="index.html"><span class="glyphicon glyphicon-cog"></span> Item</a></li>
                </ul>
<ul class="nav navbar-nav navbar-right">
    <li><a href="#">Log off</a></li>
</ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
</div>

<div class="col-xs-12 col-md-2" id="ulMenuLateral">
    <ul>
        <li><a href="index.html"><span class="glyphicon glyphicon-envelope"></span> Item</a></li>
        <li><a href="index.html"><span class="glyphicon glyphicon-shopping-cart"></span> Item</a></li>
        <li><a href="index.html"><span class="glyphicon glyphicon-list"></span> Item</a></li>
        <li><a href="index.html"><span class="glyphicon glyphicon-signal"></span> Item</a></li>
        <li><a href="index.html"><span class="glyphicon glyphicon-cog"></span> Item</a></li>
    </ul>
</div>


<div class="col-xs-12 col-md-10 content">
  <div class="col-xs-12 col-md-12 semPadding paddingCimaBaixo">
    <h1>
      Teste
    </h1>
  </div>

  • It would be interesting for you to post the "example" code here as well, so the link is only a reference to the code described.

  • OK @Diegofelipe

  • an alternative would be to take the screen size via jquery

  • 1

    You need 100% of the screen or missing space to get to the footer?

  • You want that h1 divide the page ?

  • @Celsomtrindade space missing until the footer

Show 1 more comment

2 answers

4


Let’s start from the easiest and go to the most complicated. To make the content visible, you need to add the overflow: scroll in the column.

Regarding the height: 100% which is the most complicated part of it. You need to declare a reference size that is the parent of the node. This is an old CSS problem where you can’t change the size without having a reference. Something like body: 600px.

With CSS3 an alternative called view height and view width. With it you can get 100% on any device, but you have some compatibility issues. Supports only exist for IE9+ and there is no support for Opera mini. You can browse the list here.

And follow the example of the class.

.content {
    height: 100vh;
    overflow: scroll;
}

1

In addition to the above mentioned alternative by @flpms it is possible to find out the screen size, and through jquery implement in your css this height.

var altura = $(window).height();
$(".coluna").css("height",altura);

Thus passing the height of your screen to the column, so always having 100%.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.