我有一个简单的 build 中页面,我想将我的 build 中图像与屏幕中间对齐。水平方向没问题,但垂直方向我什至无法定位图像。
这是我的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Page Under Construction</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<style type="text/css">
body {
background-color:#d7df29;
width: 100%;
height: 100%;
}
.img {
text-align: center;
margin: 0 auto
vertical-align: middle;
top:500;
}
#html5 {
position:absolute;
top:0;
right:0;
}
</style>
</head>
<body>
<div class="img"><img src="1.jpg" alt="Under Construction"></div>
<div id="html5"><img src="images/img_html5_FR.png" height="120" width="120" alt="" /> </div>
<img src="images/fb2.png" style="position: fixed; top: 350px; left: 0px;" title="Bierzyk na Facebook'u" alt="Bierzyk na Facebook'u">
</body>
</html>
最佳答案
如果您使 .img
的高度为 100%,则可以将图像设置为该 div(或 body
) 然后垂直对齐它。这应该可以工作,因为页面上的其他元素是绝对定位且固定的
关于html - 从顶部或中心垂直移动图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14686951/