<div id="my-modal" class="modal"> <span class="closed" onclick="closeModal()"> <img data-src="img/close-left-product-ui-ux-design-cover.webp" style="width: 24px; height: 24px;" alt="close button" class="img-fluid lazyload" /> </span> <div class="modal-content"> <div class="my-slides"> <img src="img/image1@2x.webp" class="img-fluid lazyload" alt="ecolight product" /> </div> </div> </div>CSS.modal { display: none; position: fixed; z-index: 1; padding-top: 50px; padding-bottom: 50px; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.8);}.modal-content { position: relative; border-radius: 4px; padding: 24px; margin-left: auto; margin-right: auto; width: 70%; max-width: 1000px; border: none; background-color: #fff;}.my-slides { width: 100%;}.my-slides img { width: 100%;}我希望我的類 modal-content 和類 my-slides 根據(jù)其中存在的高度動態(tài)增加。使用此代碼,容器高度不會增加。我有不同高度的圖像。有沒有什么辦法解決這一問題 ?
如何根據(jù)其中存在的圖像動態(tài)增加 div 高度?
慕少森
2022-07-15 10:03:42