Responsive
The popup component adapts fluidly to its environment. There are times however when you would like to set the component up responsively.
Use the responsive option to configure the popup and change the options based on the viewport width. There are five predefined breakpoints:
xsmall- min-width: 0pxsmall- min-width: 576pxmedium- min-width: 768pxlarge- min-width: 992pxxlarge- min-width: 1200px- use
customfor setting a custombreakpoint
It is a good idea to adjust the display to tailor the UX. This allows you to have the popup bottom-positioned on mobile devices, centered on tablets, and anchored to input on larger screens to enhance the user experience.
Demo
responsive: {
}
Welcome to our website!
Have fun navigating through the demos.
mobiscroll.setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
var popup = mobiscroll.popup('#demo-popup-responsive', {
responsive: {
xsmall: {
display: 'bottom',
},
small: {
display: 'center',
},
custom: {
// Custom breakpoint
breakpoint: 800,
display: 'anchored',
anchor: document.getElementById('demo-popup-show-btn'),
},
},
});
document.getElementById('demo-popup-show-btn').addEventListener('click', function () {
popup.open();
});
<div class="mbsc-form-group">
<div class="mbsc-button-group-block">
<button mbsc-button id="demo-popup-show-btn">Open popup</button>
</div>
</div>
<div id="demo-popup-responsive" style="display: none;">
<div class="mbsc-align-center mbsc-padding">
<img src="https://img.mobiscroll.com/demos/logo-noshadow.jpg">
<h4>Welcome to our website!</h4>
<p>Have fun navigating through the demos.</p>
</div>
</div>
/* style */