如何将这些图像置于此div中?

问题描述 投票:1回答:1

我似乎无法找到一种方法将图像置于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>
html css image centering
1个回答
2
投票

据我所知,主要的麻烦是.social块的绝对位置。如果这个位置真的有必要使用:

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

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

display: flex;
justify-content: center;
© www.soinside.com 2019 - 2024. All rights reserved.