html - 从顶部或中心垂直移动图像

标签 html css image

我有一个简单的 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/

相关文章:

html - CSS 和 HTML : HTML code wont take the style from the CSS

html - 如何将形状设置为div

html - CSS 流体布局缩放内容

c# - 如何根据图像的不同位置做不同的 Action (传统外观的电子书)

c# - 从 Image 实例中获取原始数据

javascript - 如何使用 CSS/Javascript 在 HTML 上防止 iOS 上的自动旋转图像

javascript - 在 Angular JS 中使用 Ng-Hide 延迟隐藏按钮

javascript - 在提交表单时打开 Bootstrap 模式

javascript - 动态将类设置为选定的 <li> 标记

css - 正文背景 100% 的文档宽度?