如何在 div 中将这些图像居中?

How do I center these images inside this div?

我似乎无法找到一种方法来使 div 中的图像居中。有什么提示吗?我知道的非常基本的东西,最近才再次进入它。我希望有人明白我在这里想做什么?

我似乎无法找到一种方法来使 div 中的图像居中。有什么提示吗?我知道的非常基本的东西,最近才再次进入它。我希望有人明白我在这里想做什么?

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
}

body {
  padding: 0;
  margin: 0;
  border: 0;
  background-color: grey;
  background-attachment: fixed;
  background-size: 100% auto;
}

ul#horizontal-list {
  list-style: none;
}

ul#horizontal-list li {
  display: inline;
}

ul {
  margin: 0;
  padding: 0;
  overflow: hidden;
}

li {
  float: center;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 16px;
  text-decoration: none;
}

li a:hover {
  background-color: red;
}

.navbar {
  position: fixed;
    top: 0;
    height: 50px;
    width: 100%;
    background-color: black;
    color: white;
    text-align: center;
    left: 0;
    right: 0;
    z-index: 1;
}

.navbar ul {
  display: flex;
  align-items: center;
  justify-content: center;
  list-style-type: none;
  margin-top: 0px;
}

.header {
 width: 100%;
 height: 100%;
 background-image: url("img/bg/background1.png");
 background-color: grey;
 background-repeat: no-repeat;
 background-size: 100% 100%;
}

.body {
  /*height: 100%;*/
  width: 100%;
  background-color: white;
  color: black;
  padding-left: 5%;
  padding-right: 5%;
  overflow: hidden;

}

.content {
 margin: auto;
 width: 100%;
 background-color: white;
 color: black;
 border-right: double;
 border-left: double;
 text-align: justify;
 font-size: 20px;
 font-family: arial;
 padding-top: 10%;
 padding-bottom: 10%;
 padding-left: 5%;
 padding-right: 5%;
}

.social {
 margin: auto;
 position: absolute;
}

.social a {

}

.footer {
  height: 50px;
  width: 100%;
  background-color: black;
  color: white;
  margin: auto;
  vertical-align: middle;
}

#copyright {
 display: table;
}

#cpy{
    display: table-cell;
    vertical-align: middle;
}
<!DOCTYPE html>

<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" href="stylesheet.css">
  <link rel="icon" type="image/x-icon" href="img/favicon.ico"/>
  <meta name="description" content="My Personal Portfolio">
  <title>John's Work</title>
</head>

<body>


  <div class="navbar">

    <ul>
      <li><a href="index.html">HOME</a></li>
      <li><a href="about.html">ABOUT</a></li>
      <li><a href="contact.html">CONTACT</a></li>
    </ul>

  </div>


  <div class="header">

  </div>

  <div class="body">
  <div class="content">
 <div class="social">
   <a href="https://www.facebook.com/" style="color:black; text-decoration:none">
    <img src="img/fb.png" alt="Facebook">
   </a>
   
   <a href="http://www.instagram.com/" style="color:black; text-decoration:none" >
    <img src="img/ig.png" alt="Instagram">
   </a>
   
   <a href="http://www.snapchat.com/" style="color:black; text-decoration:none" >
    <img src="img/snapchat.png" alt="Snapchat">
   </a>
 </div>
  </div>
</div>

  <div class="footer" id="copyright" style="text-align:center">
    <div id="cpy">&copy;)</div>
  </div>



</body>

</html>

据我了解,主要问题是 .social 块的绝对位置。如果确实需要这个职位,请使用:

left: 50%;
transform: translateX(-50%);

在其他情况下,您可以删除 position: absolute; 并添加

display: flex;
justify-content: center;