Центрирование div, когда поля и отступы равны 0?

Fidel_Willis спросил: 07 октября 2018 в 12:41 в: html

У меня есть div с классом, изображениями и всем моим телом, для которого установлены 0 полей и отступы. Но когда я пытаюсь центрировать изображения div, это немного не так, и с правой стороны появляется дополнительное пространство. Как мне это исправить?

Я попытался сделать поле: 0 auto; но там изображения отображаются немного вправо, что делает их нецентрированными и визуально непривлекательными. Спасибо за вашу помощь, очень признателен.

Код:

* {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  font-family: Georgia, 'Times New Roman', Times, serif;
}

nav {
  width: 100%;
  text-align: center;
  font-size: 1.5em;
  padding: 1em;
  background-color: #2F2F2F;
}

nav li {
  display: inline;
}

nav li a {
  margin: 1.5em;
  color: #878BCD;
  text-decoration: none;
}

.title {
  height: 200px;
  background-color: #2F2F2F;
}

.title h1 {
  text-align: center;
  font-size: 5em;
  color: #878BCD;
  margin-top: .5em;
}

.images {
  width: 90%;
  margin: 0 auto;
}

footer {
  width: 100%;
  text-align: center;
  font-size: 1.5em;
  padding: 1em;
  margin-top: 2em;
  background-color: #2F2F2F;
}

footer li {
  display: inline;
}

footer li a {
  margin: 1.5em;
  color: #878BCD;
  text-decoration: none;
}

<!DOCTYPE html>

<head>
  <meta charset="utf-8">
  <title></title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="stylesheet.css" type="text/css">
</head>

<body>
  <nav>
    <li><a href="">Home</a></li>
    <li><a href="">Shows</a></li>
    <li><a href="">Gallery</a></li>
    <li><a href="">Contact</a></li>
    <li><a href="">Resources</a></li>
  </nav>
  <div class="title">
    <h1>Gallery</h1>
  </div>
  <div class="images">
    <img src="Photos/IMG_01.JPG" alt="IMG_01" width="200" height="200">
    <img src="Photos/IMG_02.JPG" alt="IMG_02" width="200" height="200">
    <img src="Photos/IMG_03.JPG" alt="IMG_03" width="200" height="200">
    <img src="Photos/IMG_04.JPG" alt="IMG_04" width="200" height="200">
    <img src="Photos/IMG_05.JPG" alt="IMG_05" width="200" height="200">
    <img src="Photos/IMG_06.JPG" alt="IMG_06" width="200" height="200">
    <img src="Photos/IMG_07.JPG" alt="IMG_07" width="200" height="200">
    <img src="Photos/IMG_08.JPG" alt="IMG_08" width="200" height="200">
    <img src="Photos/IMG_09.JPG" alt="IMG_09" width="200" height="200">
    <img src="Photos/IMG_10.PNG" alt="IMG_10" width="200" height="200">
    <img src="Photos/IMG_11.PNG" alt="IMG_11" width="200" height="200">
    <img src="Photos/IMG_12.PNG" alt="IMG_12" width="200" height="200">
    <img src="Photos/IMG_13.PNG" alt="IMG_13" width="200" height="200">
    <img src="Photos/IMG_14.JPG" alt="IMG_14" width="200" height="200">
    <img src="Photos/IMG_15.JPG" alt="IMG_15" width="200" height="200">
    <img src="Photos/IMG_16.JPG" alt="IMG_16" width="200" height="200">
    <img src="Photos/IMG_17.JPG" alt="IMG_17" width="200" height="200">
    <img src="Photos/IMG_18.JPG" alt="IMG_18" width="200" height="200">
    <img src="Photos/IMG_19.JPG" alt="IMG_19" width="200" height="200">
    <img src="Photos/IMG_20.JPG" alt="IMG_20" width="200" height="200">
    <img src="Photos/IMG_21.JPG" alt="IMG_21" width="200" height="200">
    <img src="Photos/IMG_22.JPG" alt="IMG_22" width="200" height="200">
    <img src="Photos/IMG_23.JPG" alt="IMG_23" width="200" height="200">
    <img src="Photos/IMG_24.JPG" alt="IMG_24" width="200" height="200">
    <!-- <img src="Photos/IMG_25.MOV" alt="IMG_25" width="200" height="200"> -->
    <img src="Photos/IMG_26.PNG" alt="IMG_26" width="200" height="200">
    <img src="Photos/IMG_27.JPG" alt="IMG_27" width="200" height="200">
    <img src="Photos/IMG_28.JPG" alt="IMG_28" width="200" height="200">
    <img src="Photos/IMG_29.JPG" alt="IMG_29" width="200" height="200">
    <img src="Photos/IMG_30.JPG" alt="IMG_30" width="200" height="200">
    <img src="Photos/IMG_31.JPG" alt="IMG_31" width="200" height="200">
    <img src="Photos/IMG_32.JPG" alt="IMG_32" width="200" height="200">
    <img src="Photos/IMG_33.JPG" alt="IMG_33" width="200" height="200">
    <img src="Photos/IMG_34.JPG" alt="IMG_34" width="200" height="200">
    <img src="Photos/IMG_35.JPG" alt="IMG_35" width="200" height="200">
    <img src="Photos/IMG_36.JPG" alt="IMG_36" width="200" height="200">
    <img src="Photos/IMG_37.JPG" alt="IMG_37" width="200" height="200">
    <img src="Photos/IMG_38.JPG" alt="IMG_38" width="200" height="200">
    <img src="Photos/IMG_39.JPG" alt="IMG_39" width="200" height="200">
    <img src="Photos/IMG_40.JPG" alt="IMG_40" width="200" height="200">
    <img src="Photos/IMG_40.JPG" alt="IMG_40" width="200" height="200">
    <img src="Photos/IMG_41.JPG" alt="IMG_41" width="200" height="200">
    <img src="Photos/IMG_42.JPG" alt="IMG_42" width="200" height="200">
    <img src="Photos/IMG_43.JPG" alt="IMG_43" width="200" height="200">
    <img src="Photos/IMG_44.JPG" alt="IMG_44" width="200" height="200">
    <img src="Photos/IMG_45.JPG" alt="IMG_45" width="200" height="200">
    <img src="Photos/IMG_46.JPG" alt="IMG_46" width="200" height="200">
    <img src="Photos/IMG_47.JPG" alt="IMG_47" width="200" height="200">
    <img src="Photos/IMG_48.JPG" alt="IMG_48" width="200" height="200">
    <img src="Photos/IMG_49.JPG" alt="IMG_49" width="200" height="200">
    <img src="Photos/IMG_50.JPG" alt="IMG_50" width="200" height="200">
    <img src="Photos/IMG_51.JPG" alt="IMG_51" width="200" height="200">
    <img src="Photos/IMG_52.JPG" alt="IMG_52" width="200" height="200">
    <img src="Photos/IMG_53.JPG" alt="IMG_53" width="200" height="200">
    <img src="Photos/IMG_54.JPG" alt="IMG_54" width="200" height="200">
    <img src="Photos/IMG_55.JPG" alt="IMG_55" width="200" height="200">
    <img src="Photos/IMG_56.JPG" alt="IMG_56" width="200" height="200">
    <img src="Photos/IMG_57.JPG" alt="IMG_57" width="200" height="200">
    <img src="Photos/IMG_58.JPG" alt="IMG_58" width="200" height="200">
    <img src="Photos/IMG_59.JPG" alt="IMG_59" width="200" height="200">
    <img src="Photos/IMG_60.JPG" alt="IMG_60" width="200" height="200">
    <img src="Photos/IMG_60.JPG" alt="IMG_60" width="200" height="200">
    <img src="Photos/IMG_61.JPG" alt="IMG_61" width="200" height="200">
    <img src="Photos/IMG_62.JPG" alt="IMG_62" width="200" height="200">
    <img src="Photos/IMG_63.JPG" alt="IMG_63" width="200" height="200">
    <img src="Photos/IMG_64.JPG" alt="IMG_64" width="200" height="200">
    <img src="Photos/IMG_65.JPG" alt="IMG_65" width="200" height="200">
    <img src="Photos/IMG_66.PNG" alt="IMG_66" width="200" height="200">
    <img src="Photos/IMG_67.JPG" alt="IMG_67" width="200" height="200">
    <img src="Photos/IMG_68.JPG" alt="IMG_68" width="200" height="200">
    <img src="Photos/IMG_69.PNG" alt="IMG_69" width="200" height="200">
    <img src="Photos/IMG_70.JPG" alt="IMG_70" width="200" height="200">
    <img src="Photos/IMG_71.JPG" alt="IMG_71" width="200" height="200">
    <img src="Photos/IMG_72.JPG" alt="IMG_72" width="200" height="200">
  </div>
  <footer>
    <li><a href="">Home</a></li>
    <li><a href="">Shows</a></li>
    <li><a href="">Gallery</a></li>
    <li><a href="">Contact</a></li>
    <li><a href="">Resources</a></li>
  </footer>
</body>

</html>

0 ответов