풀 스크린 모달을위한 "반응 형"솔루션을 생각해 냈습니다.
특정 중단 점 에서만 활성화 할 수있는 전체 화면 모달 . 이러한 방식 으로 모달은 더 넓은 (데스크톱) 화면에 "일반"을 표시하고 더 작은 (태블릿 또는 모바일) 화면에 전체 화면을 표시 하여 기본 앱의 느낌을줍니다.
Bootstrap 3 및 Bootstrap 4 용으로 구현되었습니다 .
부트 스트랩 v4
다음과 같은 일반 코드가 작동해야합니다.
.modal {
padding: 0 !important; // override inline padding-right added from js
}
.modal .modal-dialog {
width: 100%;
max-width: none;
height: 100%;
margin: 0;
}
.modal .modal-content {
height: 100%;
border: 0;
border-radius: 0;
}
.modal .modal-body {
overflow-y: auto;
}
아래에 scss 코드를 포함시켜 .modal요소에 추가해야하는 다음 클래스를 생성합니다 .
+---------------+---------+---------+---------+---------+---------+
| | xs | sm | md | lg | xl |
| | <576px | ≥576px | ≥768px | ≥992px | ≥1200px |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen | 100% | default | default | default | default |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen-sm | 100% | 100% | default | default | default |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen-md | 100% | 100% | 100% | default | default |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen-lg | 100% | 100% | 100% | 100% | default |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen-xl | 100% | 100% | 100% | 100% | 100% |
+---------------+---------+---------+---------+---------+---------+
scss 코드는 다음과 같습니다
@mixin modal-fullscreen() {
padding: 0 !important; // override inline padding-right added from js
.modal-dialog {
width: 100%;
max-width: none;
height: 100%;
margin: 0;
}
.modal-content {
height: 100%;
border: 0;
border-radius: 0;
}
.modal-body {
overflow-y: auto;
}
}
@each $breakpoint in map-keys($grid-breakpoints) {
@include media-breakpoint-down($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
.modal-fullscreen#{$infix} {
@include modal-fullscreen();
}
}
}
Codepen 데모 : https://codepen.io/andreivictor/full/MWYNPBV/
부트 스트랩 v3
이 주제 (@Chris J, @kkarli)에 대한 이전 응답을 기반으로 다음 일반 코드가 작동해야합니다.
.modal {
padding: 0 !important; // override inline padding-right added from js
}
.modal .modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal .modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
반응 형 전체 화면 모달을 사용하려면 .modal요소에 추가해야하는 다음 클래스를 사용하십시오 .
.modal-fullscreen-md-down-모달은보다 작은 화면의 전체 화면입니다 1200px.
.modal-fullscreen-sm-down-모달은보다 작은 화면의 전체 화면입니다 922px.
.modal-fullscreen-xs-down-모달이 화면보다 작은 경우 전체 화면입니다 768px.
다음 코드를 살펴보십시오.
/* Extra small devices (less than 768px) */
@media (max-width: 767px) {
.modal-fullscreen-xs-down {
padding: 0 !important;
}
.modal-fullscreen-xs-down .modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal-fullscreen-xs-down .modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
}
/* Small devices (less than 992px) */
@media (max-width: 991px) {
.modal-fullscreen-sm-down {
padding: 0 !important;
}
.modal-fullscreen-sm-down .modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal-fullscreen-sm-down .modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
}
/* Medium devices (less than 1200px) */
@media (max-width: 1199px) {
.modal-fullscreen-md-down {
padding: 0 !important;
}
.modal-fullscreen-md-down .modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal-fullscreen-md-down .modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
}
데모는 Codepen ( https://codepen.io/andreivictor/full/KXNdoO )에서 사용할 수 있습니다 .
Sass를 프리 프로세서로 사용하는 사용자는 다음 믹스 인을 활용할 수 있습니다.
@mixin modal-fullscreen() {
padding: 0 !important; // override inline padding-right added from js
.modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
}
margin: 0에.modal-dialog.