Vertical scrollbar is being hidden, when Twitter Bootstrap 3 modal appears, and returns, when modal is hidden. Since certain elements on my page varies its position on whether vertical scrollbar is or isn’t visible — this produces an overall not to good looking effect:
Is there any way to prevent this and force vertical scrollbar to stay on screen all the time, even during displaying of Twitter Bootstrap 3 modal?
I’m using modals generated by Yii2 framework, but I doubt, that this is framework issue. Seems to be more like core Twitter Bootstrap 3 problem.
2
Answers
In your custom CSS file that should be loaded after the bootstrap CSS add the following code:
As you stated, the Bootstrap default code has certain preset CSS, which in this case will do
overflow: hidden
on the appearance of the modal.To fix this issue, target the modal using a selector and add
overflow: scroll
to it, and make sure it comes after the Bootstrap CSS to get priority.You could also slap an
!important
tag on it in the case that your CSS needs to come before the Bootstrap CSS for whatever reason.Hope that helps.