第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何根據(jù)其中存在的圖像動態(tài)增加 div 高度?

如何根據(jù)其中存在的圖像動態(tài)增加 div 高度?

慕少森 2022-07-15 10:03:42
<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)增加。使用此代碼,容器高度不會增加。我有不同高度的圖像。有沒有什么辦法解決這一問題 ?
查看完整描述

1 回答

?
斯蒂芬大帝

TA貢獻1827條經(jīng)驗 獲得超8個贊

您可以通過對元素使用CSS 樣式的值max-content來解決此問題,例如:height.modal-content


.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;

  height: max-content;   

}


查看完整回答
反對 回復(fù) 2022-07-15
  • 1 回答
  • 0 關(guān)注
  • 80 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號