remove div vertical scroll


Posted on : Wed, 22nd Apr 15 01:58 pm (Updated on : Wed, 22nd Apr 15 01:58 pm) UTC
Author : Code2care
2314 votes

You might have an HTML page layout with divs elements, for example a layout with a Left Div section that holds the Body/Contents of the page and the Right Div that displays Facebook Like-box, Tags and other stuffs (as this website has). You might see that the left div section may vary in size depending upon the length the contents it holds, so you might get a vertical scroll added to the right div, lets see what css properties to use to avoid the scrollbar.


You must create a container div that holds both the left and the right divs, and add the following css properties to it : height: auto !important and overflow: hidden. For the Left and the Right divs you can set a minimum height and set overflow as auto, example : min-height: 1200px and overflow: auto

Advertisements



File : sample.html Language : HTML
<div class="container">
    <div class="leftSection">
        <p>contents of Left side</p>
    </div>
    <div class="rightSection">
        <p>contents of Right side</p>
    </div>
</div>


layout.css Language : Css
.container-box {

    width: 700px;
    min-height: 900px;
    height: auto !important;
    overflow: hidden;
    margin-left: auto;
    margin-right: auto;
  
}
.rightSection {
    width: 500px;

    background:#ddd;
    min-height: 1600px;
    float: right;
    overflow: auto;
    margin-top: 0px;
    display: inline-block;
    text-align: center;
}
.leftSection {
    width: 200px;
    min-height: 1600px;
    float: left;
    background:#eee;
    overflow: auto;
    display: inline-block;
    text-align: center;
}

Code2care's mission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.

Follow us : Facebook - Twitter - Google +