对中问题
我似乎无法让它发挥作用。
http://www.keironlowe.host56.com
我需要的是具有低不透明度图像的横幅无论分辨率如何,都要使其居中,我尝试过包装器,但因为包装器的宽度为 800,所以它会剪切图像,我尝试过 margin:0 auto;我什至尝试过使用该标签,但它仍然没有以更高的分辨率居中。
I cant seem to get this to work.
http://www.keironlowe.host56.com
What I need is the banner with the low opacity image on it to be centered no matter the resolution, Ive tried a wrapper but because the wrapper is a width of 800 it cuts of the image, i've tried margin:0 auto; and i've even tried using the tag but it still doesnt center in higher resolutions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您不应该需要@Logan 示例中的标签。无论如何,该标签已被弃用。在样式表中设置宽度(不是自动)并将 margin-left 和 margin-right 设置为“auto”应该可以很好地处理居中。
You shouldn't need the tags in @Logan's example. That tag is deprecated anyway. Setting a width (not auto) and setting margin-left and margin-right to 'auto' in your stylesheet should handle the centering just fine.
尝试将居中和图片从 CSS 中取出并放入 HTML 中。 css 看起来像这样:
你的 HTML 看起来像这样:
这就是我要做的。
Try taking the centering and pic out of the CSS and into the HTML. the css would look like this:
and your HTML would look like this:
That is what I would do.
首先,删除
周围的
标记。您不需要它并且它已被弃用。
然后,交换以下块的当前 CSS:
为此:
交换了速记的许多背景属性。由于您将图像显示为背景,因此添加到
center
的background-position
属性中。现在,这会将您的图像瞄准中心。First, get rid of that
<center>
tag you have around the<div id="banner"></div>
. You don't need it and it's deprecated.Then, swap out your current CSS of the following block:
For this:
Swapped out the many background attributes for the shorthand. Since you're showing the image as a background, added in the
background-position
property ofcenter
. This will now bullseye your image into the centre.