我正在寻找将我的图像放置在屏幕中间的位置,可能在左边或右边,但是我正在寻求有关如何将图像放置到我感觉到的位置的帮助,如果您认为自己在,请更正我的html / css使其变得太难/不正确-预先感谢-英里
编辑:对于那些想知道此页面是什么的人,这是一个带有背景图像的入口页面,另一个图像显示“在此处输入”,该图像超链接到我的实际网站的索引。
<html>
<head>
<title>Enter</title>
<link rel="stylesheet" href="style1.css">
</head>
<body background="index1background.jpg">
<div id="enterhere">
<p><a href="index2.html" title="Enter Here"><img src="index1enter.png"
alt="Enter Here"</a></p>
</div>
</body>
</html>
CSS:
#enterhere {
position: middle;
}
img {
margin-left: auto;
margin-right: auto;
display: block;
}
然后您可以添加padding
以向左和向右调整。该text-align: center
不会在这种情况下工作。
编辑:如果您想更短一些,这是一个较短的版本。
margin: 100px auto 0 auto;
此代码段包含margin-top
的100px
。运作方式如下。而不是使用关键字margin-top
,margin-right
等,而是使用主关键字just margin
。然后的职位:
margin: [top] [right] [bottom] [left];
这同样适用padding
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句