我想将大小为1920x225px的横幅图像置于960px宽的div中。 出现的问题是图像从左上角开始不在中心。 下面是描述问题的图像 http://tinypic.com/r/scco0m/5
答案 0 :(得分:1)
尝试使用
background-position: center center;
在你的背景图片上。
https://developer.mozilla.org/en-US/docs/Web/CSS/background-position
答案 1 :(得分:0)
你在这里没有提到,你如何在网站上添加他的图像
如果您要提供背景图片
像这样background:url(../image.jpg) center center no-repeat;
如果您不想要背景图片,只需为该图片提供max-width:100%
新答案。
您需要为宽度为960px
的div提供position:relative
并为图像添加
img{position:absolute; left:50px; top:20px; z-index:999}
您可以根据您的愿望
更改左侧和最高值