Javascript-форум (https://javascript.ru/forum/)
-   (X)HTML/CSS (https://javascript.ru/forum/xhtml-html-css/)
-   -   Убрать отступы в блоке (https://javascript.ru/forum/xhtml-html-css/70699-ubrat-otstupy-v-bloke.html)

Asperant 26.09.2017 15:28

Убрать отступы в блоке
 
Откуда появились это отступы в внутренних блоках? Хочу их убрать но без минусового margin https://jsfiddle.net/n30fkp2p/

рони 26.09.2017 15:53

Asperant,
<!DOCTYPE html>

<html>
<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">
  * {
      padding: 0;
      margin: 0;
      box-sizing: border-box;
    }
    .ad1 {
      display: flex;
      width: 200px;
      height: 305px;
      border: 1px solid #000;
      margin: 30px;
      flex-wrap: wrap;
    }
    .ad1 > * {
      border: 1px solid #000;
    }
    .ad2 {
      height: 42px;
      width: 100%;
    }
    .ad3 {
      height: 263px;
      width: 27px;
    }
    .ad5 {
      height: 263px;
      width: 27px;
    }
    .ad4 {  flex: 1;
      height: 263px;
      width: 136px;
    }
  </style>

</head>

<body>
<div class="ad1">
    <div class="ad2"></div>
    <div class="ad3"></div>
    <div class="ad4"></div>
    <div class="ad5"></div>
  </div>

</body>
</html>

Rasy 26.09.2017 16:07

Asperant,
Сымитируй таблицами, или используй модуль флексбокса. С блочно-строчным подходом больше возьни.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }
    .ad1 {
      *!*
      display: table;
      */!*
      width: 200px;
      margin: 30px;
      height: 305px;
    }
    .ad1 > * {
      display: table-cell;
      height: 258px;
      outline: 1px solid #000;
    }
    .ad2 {
      display: table-row;
      width: 100%;
      height: 42px;
    }
    .ad3 {
      width: 32px;
    }
    .ad4 {
      width: 136px;
    }
    .ad5 {
      width: 32px;
    }
  </style>
</head>
<body>
<div class="ad1">
  <div class="ad2"></div>
  <div class="ad3"></div>
  <div class="ad4"></div>
  <div class="ad5"></div>
</div>
</body>
</html>


Часовой пояс GMT +3, время: 06:34.