I am creating a lightning web component called by a quick action (using Aura). I'am trying to make my modal to behave like this:
However I got this:
Both are zoomed 110%. Problem is the header, content and footer oversized the modal like this:
I'am new to CSS and JS, so I need your help to make this right. Thank you so much. Here is my code:
HTML:
<template>
<div class="modal-container slds-modal__container">
<header class="modal-header slds-modal__header">
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close">
<lightning-icon icon-name="utility:close"
alternative-text="close"
variant="inverse"
size="small" ></lightning-icon>
<span class="slds-assistive-text">Close</span>
</button>
<h2 id="modal-heading-01" class="slds-modal__title slds-hyphenate">Convert Lead</h2>
</header>
<div class="modal-body scrollable slds-modal__content slds-p-around--medium" id="modal-content-id-1">
<p>Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore quis
aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.</p>
<p>Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt nostrud
ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.</p>
</div>
<footer class="slds-modal__footer">
<button class="slds-button slds-button_neutral">Cancel</button>
<button class="slds-button slds-button_brand">Convert</button>
</footer>
</div>
</template>
CSS:
div {
display: block;
}
.slds-modal__footer{
flex-shrink: 0;
}
.modal-container {
width: 90%;
max-width: 1024px;
min-width: 640px;
}
.slds-modal__container{
padding: 0;
}
Best Answer
It looks like your
min-width
andwidth
are fighting the size of your browser. I would move your.modal-container
styles into a media query, like this:This way when your browser window drops below 48em (pretty standard breakpoint), it'll use the standard styles from
.slds-modal__container
. By default, it doesn't have awidth
,min-width
, ormax-width
applied. Which is probably what you want on a small device.If you wish to refine your mobile styles on this modal, you could add styles to
.modal-container
outside of the media query.