亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

如何使用CSS中的邊距屬性將一個部分移動到另一個部分下方

如何使用CSS中的邊距屬性將一個部分移動到另一個部分下方

慕萊塢森 2022-12-29 13:56:01
我有一個 html 頁面,主頁上有很多部分,我有如下兩個部分:<div class='first section'>  <a href=''>    <button style='background: linear-gradient(to bottom, #cc99ff 0%, #ff99cc 100%);'>          <h3> HMT Rice</h3>          </button>  </a></div><div class='second section'>  <a href=''>    <button style='background: linear-gradient(to bottom, #cc99ff 0%, #ff99cc 100%);'>          <h3> PKS Rice</h3>          </button>  </a></div>我使用 margin-top 屬性將第一部分降低一點,但它只是在上方和上方創建了一個空白。我只想使用 css 制作第二部分下方的第一部分,如下圖所示:無論如何,是否可以使用 z-index 或其他方式將第一部分直接放在下面。請幫忙。提前致謝
查看完整描述

1 回答

?
慕虎7371278

TA貢獻1802條經驗 獲得超4個贊

您可以嘗試使用以下 HTML 和 CSS。


.section{

    position: relative;

}

.second_section{

    margin-top: 0px;

}

.first_section{

   position: absolute;

   margin-top: 70px; /* Adjust this margin top pixed according to the space you needed. */

}

<div class="section">

    <div class="first_section">

      <a href=''>

        <button style='background: linear-gradient(to bottom, #cc99ff 0%, #ff99cc 100%);'>


          <h3> HMT Rice</h3>

          </button>

      </a>

    </div>


    <div class="second_section">

      <a href=''>

        <button style='background: linear-gradient(to bottom, #cc99ff 0%, #ff99cc 100%);'>


          <h3> PKS Rice</h3>

          </button>

      </a>

    </div>

</div>

我已通過檢查元素解決了您網站中的問題。請遵循以下代碼。


您應該使用slide-button-wrapper div包裝按鈕 div 和滑塊 div并添加 css。


<div class="slide-button-wrapper">            

    <div class="mainsme" id="grid">


      <h2 style="font-size:28px;">Shop by Category</h2>

      <div class="gridmine">

         <!---buttons will goes here-->

      </div>


    </div>

                     

    <div class="main-row slider-section" style="order: 1;">

        <banner codes are here>

    </div>

</div>



@media only screen and (max-width: 600px) {

        .slide-button-wrapper {

            display: flex;

            flex-direction: column;

        }

        

        .mainsme{

          order: 2;

        }

        .slider-section{

          order: 1

        }`

    }


查看完整回答
反對 回復 2022-12-29
  • 1 回答
  • 0 關注
  • 132 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號