Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrollbar on a specific div into bootstrap modal body

My modal-body has two div side by side, one of them must have a scrollbar if his content is too big for the modal. Unfortunately, the scrollbar appears on the modal-body, not on my div.

What I have:

enter image description here

What I want:

enter image description here

My panelGuest has the overflow-y to auto, I tried with 'scroll' instead but the scrollbar is shown but not available. I tried different values for overflow on the modal-body, in vain.

css:

#panelGuest{
    overflow-y:auto;
    overflow-x:hidden;
    width: 35%;
    float:left;
    border-right:solid #ff920a 2px;
    min-height:100px;
}

html:

 <div id="modalShareBody" class="modal-body">
        <div id="panelGuest" class="panel">
            The div where i want the y-scrollbar
        </div>
        <div id="panelDetail" class="panel">
        </div>
    </div>

Here a fiddle with the issue: http://jsfiddle.net/Ua2HM/2/

like image 589
Getz Avatar asked May 15 '13 09:05

Getz


People also ask

How do I add a scroll to a specific div?

For vertical scrollable bar use the x and y axis. Set the overflow-x:hidden; and overflow-y:auto; that will automatically hide the horizontal scroll bar and present only vertical scrollbar. Here the scroll div will be vertically scrollable.

How do I add a scrollbar to a modal?

Use the . modal-dialog-scrollable class to enable scrolling inside the modal.

How do I make a bootstrap modal scrollable?

It is very simple to make bootstrap modal scrollable, you just need to add max-height, overfolw-y to add scrollbar in Modal content.

Can a div have a scroll bar?

In HTML, there is a division container - or <div></div> - that can encapsulate HTML data and elements. This data can then be manipulated using CSS styling and JavaScript. Among other features, you can also add a scrollbar to your div container with CSS.


1 Answers

I did it making the height of the modal a fixed value:

#modalShare {
    margin-left:-200px;
    height: 300px;
 }

@media (max-width: 767px) {
    #modalShare {
        width: auto;
        margin-left: auto;
    }
}

#modalShareBody {
    overflow:hidden;
}

#panelGuest{
    width: 35%;
    float:left;
    height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    border-right:solid #ff920a 2px;
}

#panelDetail{
    float:left;
    width: 60%;
}

Is that what you need?

like image 178
imcconnell Avatar answered Nov 03 '22 00:11

imcconnell