twitter bootstrap 3 - Dynamically add or remove height and overflow-Y scroll property of a div using javascript -
i have 2 sections [divs] on page based on bootstrap. left section contains bootstrap panel resized occupy full page , on clicking glyph on panel header, right section slides in sharing page left panel. contents of right section panels contents dynamic[table , dynamic rows]. left panel coded occupy window height. want right side div occupy window height , overflow let scroll appear right hand section. if hard code height of right hand section , give overflow-y: scroll, works. want provide both using javascript , height window width. please help.
<body style = "height: 100%; overflow:hidden;"> <div id="navigationbar"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mynavbar"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">tramm</a> </div> <div class="collapse navbar-collapse" id="mynavbar"> <ul class="nav navbar-nav navbar-right" id="menu"> <li><a href="">home</a></li> <li><a href="">page1</a></li> <li><a href="">page2</a></li> <li><a href="">page3</a></li> <li><a href="">page4</a></li> </ul> </div> </div> </nav> </div> <div id="wrapper"> <div id="main-wrapper" class="col-sm-6"> <div class="panel panel-info" style="margin-top: 1%"> <div class="panel-heading" id="jnname"> <div class="row"> <div class="col-sm-8"> name : somename </div> <div class="col-sm-4" style="text-align: right;"> <span class="toggle-button bs-tooltip" id="showbutton" style="cursor: pointer" data-toggle="tooltip" data-placement="left" title="click toggle sidebar"> <span id="glyphbutton" class="glyphicon glyphicon-backward"></span> </span> </div> </div> </div> <div class="panel-body" id="svgpanel"> </div> </div> </div> <div id="sidebar-wrapper" class="col-sm-6 sidebar"> <div class="panel panel-info" style="margin-top: 1%;" id="junctionparam"> <div class="panel-heading" id="junctionparameters">junction parameters</div> <div class="panel-body"> <p> please fill content more window height here... </p> </div> </div> </div> </div> </body>
and have tried this. not seem working
function autoadjust() { var $sidebarwrapperscroller; $sidebarwrapperscroller = document.getelementbyid('sidebar-wrapper'); $sidebarwrapperscroller.style.height = $(window).height(); alert("setheight"); $sidebarwrapperscroller.style.overflowy = "scroll"; }
but without javascript, if set
<div id="sidebar-wrapper" class="col-sm-6 sidebar" style="height: 700px; overflow-y:scroll;">
then working. want height set window height dynamically.
if understood you need add overflow-y:scroll , height:auto sidebar-wrapper ? maybe jquery?
$("#sidebar-wrapper").click(function() { if ( $("#sidebar-wrapper").css('display') == 'visible' ){ $("#sidebar-wrapper").css({"height":"auto", "overflow-y":"scroll"}); }else{ $("#sidebar-wrapper").css({"height":"", "overflow-y":""}); } });
replace sidebar-wrapper id glyph id in .click function
Comments
Post a Comment