HTML CSS 图像不会居中

norbik543

我有问题:尽管我使用了text-aligne:center;但我的图片不想居中display:block;并且margin: 0 auto;

这是一张图片

http://imgur.com/a/jafpQ

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background-attachment: fixed;
  background-size: 100%;
}

#container {
  max-width: 1000px;
  margin: 0 auto;
}

#Logo {
  text-align: center;
}
<!DOCTYPE HTML>
<html lang="pl">

<head>
  <meta charset="utf-8" />
  <title>str</title>
  <meta name="description" content=" bbbbbbb" />
  <meta name="keywords" content="bablal" />
  <meta http-equiv="X-UA-COMPATIBLE" content="IE=edge.chrome=1" />
  <link rel="stylesheet" href="new.css" type="text/css" />
  <link href="https://fonts.googleapis.com/css?family=Oxygen:300,400&amp;subset=latin-ext" rel="stylesheet">
</head>

<body background="photo/ik.png">
  <div id="container">
    <div id="Logo">
      <img src="photo/lg.png" width="800" height="533.5">
    </div>
  </div>
</body>

</html>

阿斯拉姆

使用Flexbox.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background-attachment: fixed;
  background-size: 100%;
}

#container {
  background: yellow;
  height: 100vh;
  width: 100vw;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}
<div id="container">
  <div id="Logo">
    <img src="http://placehold.it/200x100/333333">
  </div>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章