在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5  HTML/ css 如何讓等分列的間距自適應

css 如何讓等分列的間距自適應

我的頁面想實現(xiàn)一行放四個書籍封面,每個封面寬度固定,如果縮放瀏覽器,間距隨之縮小。
我現(xiàn)在問題是,不知道怎么讓間距能根據(jù)瀏覽器寬度自適應。另外,希望整體最左和最右是沒有邊距的。
請教一下大家思路。
圖片描述

我的代碼:

<div class="four_cover">
       <div class="row">
        <div class="cover">
          <img src="../images/book2.jpg" alt="斷代">
          <h3 class="title">斷代</h3>
          <p class="author_small">郭強生</p>
        </div>
       </div>

       <div class="row">
        <div class="cover">
          <img src="../images/book3.jpg" alt="觀山海">
          <h3 class="title">觀山海</h3>
          <p class="author_small">杉澤 / 梁超</p>
        </div>  
       </div>

       <div class="row">
        <div class="cover">
          <img src="../images/book4.jpg" alt="魚翅與花椒">
          <h3 class="title">魚翅與花椒</h3>
          <p class="author_small">[英] 扶霞·鄧洛普</p>
        </div>  
       </div>

       <div class="row">
        <div class="cover">
          <img src="../images/book5.jpg" alt="大雪將至">
          <h3 class="title">大雪將至</h3>
          <p class="author_small">[奧地利]羅伯特?澤塔勒</p>
        </div>  
       </div>
      </div>

css:

.four_cover {
    margin: 0 20px 0 20px;
}


.row {
    width: 100%;
    box-sizing: border-box;
    display: inline;


    .cover {
      float: left;
      width: 200px;
      height: 290px;
      
      box-shadow: 0px 4px 12px 0px rgba(0,0,0,.1);
      margin: 0 114px 0 0;

  


      img { 
          width: 100%;
          height: 100%;
          border-radius: .5rem 0 0 .5rem; 
          

      }
      .title {
          font-size: 1.25rem;
          font-weight: 500;
          margin: 1rem 0 0 0;
          line-height: 1.875rem;

      }
      .author_small {
        font-size: 0.875rem;
        color: $T3;
        line-height: 1.675rem;
        margin: 0;
      }

    }
    
}
}
回答
編輯回答
失魂人

個人建議用彈性布局
其他想法用 display:table 也可以試試

2018年5月29日 15:31
編輯回答
乖乖噠

可以用flex嗎

2018年2月6日 15:39
編輯回答
雨蝶

可以用flex布局,父元素加:
display: flex;
justify-content: space-between;

2017年5月11日 08:45
編輯回答
入她眼

建議用flex布局,有一個對齊選項是space between,正好滿足要求。

也可以用calc函數(shù)計算中間的邊距:

.cover {
    margin: 0;
}

.cover ~ .cover {
    margin-left: calc(33.333% - 266.667px);
}
2017年2月12日 10:36
編輯回答
誮惜顏

我這里寫了一個比較簡單的:
https://codepen.io/Ash-sc/pen...

具體是這么個想法吧:
圖片div使用display:inline-block;然后使用百分比寬度。
圖片div的父級添加font-size: 0;防止圖片div換行。
圖片div設置text-align:center;使圖片居中。

2017年4月30日 03:16
編輯回答
陌如玉

用calc呢

2017年4月26日 21:29
編輯回答
朕略傻

用table布局
或每列寬度固定百分之25
...

2018年7月30日 02:45