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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

我想將圖像與 div 的中心對(duì)齊

我想將圖像與 div 的中心對(duì)齊

長(zhǎng)風(fēng)秋雁 2023-10-10 18:08:26
我嘗試將文本對(duì)齊屬性與顯示塊一起使用,但這也不起作用。我想要一個(gè)覆蓋整個(gè)網(wǎng)頁(yè)的 div,山圖像中心在其底部對(duì)齊。我設(shè)法通過(guò)設(shè)置bottom:0;將山圖像移動(dòng)到底部。但后來(lái)我無(wú)法居中對(duì)齊圖像。非常感謝。 <!-- following is the html code: -->    <body>      <div class="topcontainer">        <img class="topcloud" src="images/newcloud.png" alt="cloud-image">        <h1>I'm Mohit</h1>        <p class="occupation">A <span>pro</span>grammer</p>        <img class="bottomcloud" src="images/newcloud.png" alt="cloud-image">        <img class="mountain" src="http://seanhalpin.io/assets/img/content/home/masthead/land.svg" alt="">      </div>    </body>    <!-- and this is the css: -->    body {      margin: 0;      text-align: center;      font-family: 'Merriweather', serif;    }    h1 {      margin: 0;      font-family: 'Sacramento', cursive;      font-size: 70px;      color: #30e3ca;    }    h2 {      font-family: 'Montserrat', sans-serif;    }    h3 {      font-family: 'Montserrat', sans-serif;    }    span {      text-decoration: underline;    }    .mountain {      display: inline-block;      position: absolute;      bottom: 0;    }    .topcontainer {      display: inline-block;      background-color: #e4f9f5;      margin-bottom: 20px;      height: 100vh;      width: 100%;      position: relative;    }    .bottomcloud {      position: absolute;      left:300px;      height: 94.28px;      width: 177.3333px;    }    .topcloud {      position: relative;      left: 290px;      height: 94.28px;      width: 177.3333px;    }
查看完整描述

2 回答

?
呼如林

TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超3個(gè)贊

我稍微編輯了代碼以實(shí)現(xiàn)您想要的效果,只需將父 div 添加到圖像標(biāo)簽并設(shè)置其樣式即可。所以這是我的解決方案,希望對(duì)您有所幫助。HTML:


<body>

      <div class="topcontainer">

        <img class="topcloud" src="images/newcloud.png" alt="cloud-image">

        <h1>I'm Mohit</h1>

        <p class="occupation">A <span>pro</span>grammer</p>

        <img class="bottomcloud" src="images/newcloud.png" alt="cloud-image">

        <div class="mountain">

            <img class="mountain" src="http://seanhalpin.io/assets/img/content/home/masthead/land.svg" alt="">

        <div>

      </div>

    </body>

CSS:


 body {

      margin: 0;

      text-align: center;

      font-family: 'Merriweather', serif;

    }


    h1 {

      margin: 0;

      font-family: 'Sacramento', cursive;

      font-size: 70px;

      color: #30e3ca;

    }


    h2 {

      font-family: 'Montserrat', sans-serif;

    }


    h3 {

      font-family: 'Montserrat', sans-serif;

    }


    span {

      text-decoration: underline;

    }


    .mountain {

      display: flex;

      justify-content: flex-end;

      align-items: center;

      position: absolute;

      bottom: 0;

    }


    .topcontainer {

      display: inline-block;

      background-color: #e4f9f5;

      margin-bottom: 20px;

      height: 100vh;

      width: 100%;

      position: relative;

    }

    .bottomcloud {

      position: absolute;

      left:300px;

      height: 94.28px;

      width: 177.3333px;

    }


    .topcloud {

      position: relative;

      left: 290px;

      height: 94.28px;

      width: 177.3333px;

    }



查看完整回答
反對(duì) 回復(fù) 2023-10-10
?
拉丁的傳說(shuō)

TA貢獻(xiàn)1789條經(jīng)驗(yàn) 獲得超8個(gè)贊

這里最簡(jiǎn)單的解決方案是在 CSS 中制作 div 背景圖像,而不是使用圖像標(biāo)簽。像這樣的東西:


<div class="topcontainer">

   //other stuff in here 

</div>

.topcontainer {

height: 100vh;

width: 100vw;

background-image: url('http://seanhalpin.io/assets/img/content/home/masthead/land.svg');

background-repeat: no-repeat;

background-position: bottom;

}


希望這可以幫助!


查看完整回答
反對(duì) 回復(fù) 2023-10-10
  • 2 回答
  • 0 關(guān)注
  • 163 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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