Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save quantumwebco/a08c94e1d1b6dc6e19ca93d370e1cd66 to your computer and use it in GitHub Desktop.
Save quantumwebco/a08c94e1d1b6dc6e19ca93d370e1cd66 to your computer and use it in GitHub Desktop.
A Sass snippet to make bootstrap modals more mobile friendly by turning them into a 'bottom sheet' on smaller screens
.modal {
display: flex;
align-items: flex-end;
&.fade {
.modal-dialog-bottom {
position: absolute;
bottom: 0;
transition: transform 0.4s;
transform: translate(0, 100%);
margin: 0 auto 0;
left: 0;
right: 0;
max-height: 100vh;
@media (min-width: 767.98px) {
bottom: 50%;
transform: translate(0, 50%);
}
.modal-content {
overflow-y: visible;
border-radius: 0;
}
}
}
&.show {
.modal-dialog-bottom {
transform: translate(0, 0);
@media (min-width: 767.98px) {
transform: translate(0, 50%);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment