填充佔用了額外空間,我希望我的 div 像引導 div 一樣 (padding is taking up extraspaces,i want my div's to act like bootstrap div's)


問題描述

填充佔用了額外空間,我希望我的 div 像引導 div 一樣 (padding is taking up extraspaces,i want my div's to act like bootstrap div's)

我製作了四個 div,每個 25% 並將它們浮動到左側。現在,當我為每個 div 提供填充時,最後一個 div 不能包含在一行中並向下移動,因為每個 div 佔用的空間都比給定的 25% 多,如下所示:

<div class="container">
  <div class="abc">
  </div>
  <div class="abc">
  </div>
  <div class="abc">
  </div>
  <div class="abc">
  </div>
</div>
.container {
  width: 100%;
  height: auto;
}
.abc {
  width: 25%;
  float: left;
  padding: 15px;
}

但是當我查看引導 div 時,讓我們說一下 col‑lg‑4 div。col‑lg‑4 div 的比例為 33.33%,並且左右兩邊的內邊距為 15px,並且仍然適合同一行。我希望我的 div 以同樣的方式行事。我在這裡錯過了什麼?


參考解法

方法 1:

Use box‑sizing: border‑box; on the .abc divs. This will cause the width (and height) calculation to include the border and padding.

(by AshishDerek)

參考文件

  1. padding is taking up extraspaces,i want my div's to act like bootstrap div's (CC BY‑SA 2.5/3.0/4.0)

#padding #css #twitter-bootstrap #html






相關問題

'android:paddingRight' 與 'android:drawableRight' 一起使用 (’android:paddingRight’ working with ‘android:drawableRight’)

雙行導航欄 - 是什麼原因造成的? (double row navigation bar- what's causing it?)

在 Twitter 引導程序中為行添加背景顏色和填充 (Adding background color and padding to row in Twitter bootstrap)

如何控制 addView 到佈局 (How to control addView to a layout)

Ці можа выкарыстанне працэнтаў для вышыні запаўнення/поля/межы быць лепшым, чым em? (Can using percentages for height of padding/margin/border be better than em?)

填充對絕對定位的下拉菜單有意想不到的影響 (Padding has unexpected effect on drop down menu with absolute postioning)

內部 div 相對於包裝器具有不需要的空間 (Inner div has unwanted space in relation to wrapper)

css @font-face 不會在所有瀏覽器中垂直對齊文本 (css @font-face doesn't align text vertically across all browsers)

填充佔用了額外空間,我希望我的 div 像引導 div 一樣 (padding is taking up extraspaces,i want my div's to act like bootstrap div's)

Android -- 使用帶有自定義背景的 ListView 時如何刪除那一點額外的填充? (Android -- How to remove that little extra padding when using a ListView with custom background?)

使用顯示時沒有底部填充:網格和滾動 (No bottom padding when using display: grid and scroll)

TCL 中的零填充 (zero padding in TCL)







留言討論