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
310 views
in Technique[技术] by (71.8m points)

javascript - Bootstrap Off Canvas Show Full Height

I am trying to use Bootstrap off canavas left side bar to toggle on small devices.

here is the bootply code example:

www.bootply.com/C2wQEkdSAn

The problem when displaying on mobile when you click on the accordion the contents are not pushing the footer down but hides behind it.

enter image description here

Here is the full code:

<!doctype html> <html lang="en">  <head>

  <link href="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script src="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

<style> /*a  * Style tweaks  *
--------------------------------------------------  */ body {   padding-top: 70px; } footer {   padding-left: 15px;   padding-right: 15px; }

/*  * Off Canvas  * --------------------------------------------------
*/ @media screen and (max-width: 768px) {   .row-offcanvas {
    position: relative;
    -webkit-transition: all 0.25s ease-out;
    -moz-transition: all 0.25s ease-out;
    transition: all 0.25s ease-out;   }

  .row-offcanvas-left   .sidebar-offcanvas {
    left: -50%;   }

  .row-offcanvas-left.active {
    left: 50%;   }

  .sidebar-offcanvas {
    position: absolute;
    top: 0;
    width: 50%;
    margin-left: 12px;   } } </style>

 </head>  <body>    <div class="navbar navbar-fixed-top navbar-inverse" role="navigation">   <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Project name</a>
    </div>
    <div class="collapse navbar-collapse">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#about">About</a></li>
        <li><a href="#contact">Contact</a></li>
      </ul>
    </div><!-- /.nav-collapse -->   </div><!-- /.container --> </div><!-- /.navbar -->

<div class="container">

  <div class="row row-offcanvas row-offcanvas-left">

     <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation">

       <p class="visible-xs">
        <button type="button" class="btn btn-primary btn-xs" data-toggle="offcanvas"><i class="glyphicon glyphicon-chevron-left"></i></button>
      </p>

      <div class="well sidebar-nav">
        <ul class="nav">
          <li>Sidebar</li>
          <li class="active"><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
          <li>Sidebar</li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
          <li>Sidebar</li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
          <li><a href="#">Link</a></li>
        </ul>

        <div class="accordion" id="accordion2">
            <div class="accordion-group">
                <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                        Collapsible Group Item #1
                    </a>
                </div>
                <div id="collapseOne" class="accordion-body collapse">
                    <div class="accordion-inner">
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                    </div>
                </div>
            </div>
            <div class="accordion-group">
                <div class="accordion-heading">
                    <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                        Collapsible Group Item #2
                    </a>
                </div>
                <div id="collapseTwo" class="accordion-body collapse">
                    <div class="accordion-inner">
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
                        Sidebar text...<br>
              

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

1 Reply

0 votes
by (71.8m points)

Her's a complete page:

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta content="" name="description">
<meta content="" name="author">
<link href="../../docs-assets/ico/favicon.png" rel="shortcut icon">

<title>Starter Template for Bootstrap</title><!-- Bootstrap core CSS -->
<link href=
"http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel=
"stylesheet">
<link href=
"http://cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/3.1.3/css/jasny-bootstrap.min.css"
rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->

<style>
            body {
                    padding-top: 50px;
                }
                .content_wrap {
                    padding: 40px 15px;
                    text-align: center;
                }
                footer {
                    background-color: #222;
                    color: #777;
                }
                /*  * Off Canvas  * --------------------------------------------------
                */ @media screen and (max-width: 768px) {
                            .row-offcanvas {
                            }
                            #sidebar {
                                display:none;
                            }
                            #sidebar.in {
                                display:block;
                                position: fixed;
                                z-index: 1030;
                                top: 0px;
                                bottom: 0px;
                                overflow-y: auto;
                                border-radius: 0px;
                                padding:0px;
                                min-height:100%;
                                width:300px;
                            }
                            #sidebar.in .well {
                                margin:0px;
                                border-radius: 0px;
                                border:none;
                                min-height:100%;
                            }
                }
    </style>
 </head>

<body>
 <div class="navmenu navmenu-default navmenu-fixed-left offcanvas">
    <a class="navmenu-brand" href="#">Project name</a>

    <ul class="nav navmenu-nav">
        <li>
            <a href="../navmenu/">Slide in</a>
        </li>

        <li class="active">
            <a href="./">Push</a>
        </li>

        <li>
            <a href="../navmenu-reveal/">Reveal</a>
        </li>

        <li>
            <a href="../navbar-offcanvas/">Off canvas navbar</a>
        </li>
    </ul>

    <ul class="nav navmenu-nav">
        <li>
            <a href="#">Link</a>
        </li>

        <li>
            <a href="#">Link</a>
        </li>

        <li>
            <a href="#">Link</a>
        </li>

        <li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" href=
            "#">Dropdown <b class="caret"></b></a>

            <ul class="dropdown-menu navmenu-nav">
                <li>
                    <a href="#">Action</a>
                </li>

                <li>
                    <a href="#">Another action</a>
                </li>

                <li>
                    <a href="#">Something else here</a>
                </li>

                <li class="divider"></li>

                <li class="dropdown-header">Nav header</li>

                <li>
                    <a href="#">Separated link</a>
                </li>

                <li>
                    <a href="#">One more separated link</a>
                </li>
            </ul>
        </li>
    </ul>
</div>

<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button class="navbar-toggle" data-target=".navbar-collapse"
            data-toggle="collapse" type="button"><span class=
            "icon-bar"></span> <span class="icon-bar"></span> <span class=
            "icon-bar"></span></button> <a class="navbar-brand" href=
            "#">Project name</a>
        </div>

        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li class="active">
                    <a href="#">Home</a>
                </li>

                <li>
                    <a href="#about">About</a>
                </li>

                <li>
                    <a href="#contact">Contact</a>
                </li>
            </ul>
        </div><!--/.nav-collapse -->
    </div>
</div>

<div class="container content_wrap">
    <div class="row">
        <div class="col-xs-6 col-sm-3" id="sidebar">
            <div class="well sidebar-nav">
                <ul class="nav">
                    <li>Sidebar</li>

                    <li class="active">
                        <a href="#">Link</a>
                    </li>

                    <li>
                        <a href="#">Link</a>
                    </li>

                    <li>
                        <a href="#">Link</a>
                    </li>

                    <li>
                        <a href="#">Link</a>
                    </li>

                    <li>Sidebar</li>

                    <li>
                        <a href="#">Link</a>
                    </li>

                    <li>
                        <a href="#">Link</a>
                    </li>

                    <li>
                        <a href="#">Link</a>
                    </li>

                    <li>
                        <a href="#">Link</a>
                    </li>

                    <li>Sidebar</li>

                    <li>
                        <a href="#">Link</a>
                    </li>

                    <li>
                        <a href="#">Link</a>
                    </li>

                    <li>
                        <a href="#">Link</a>
                    </li>
                </ul>

                <div class="accordion" id="accordion2">
                    <div class="accordion-group">
                        <div class="accordion-heading">
                            <a class="accordion-toggle" data-parent=
                            "#accordion2" data-toggle="collapse" href=
                            "#collapseOne">Collapsible Group Item #1</a>
                        </div>

                        <div class="accordion-body collapse" id=
                        "collapseOne">
                            <div class="accordion-inner">
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                                Sidebar text...<br>
                         

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

...