大图片根据分辨率自适应宽度仍居中显示
发布时间:2016-12-27 来源:查字典编辑
摘要:问题:一个1920*900的大图,在1024*768的分辨率只能显示一部分,希望仍居中显示解决方案CSS:width:100%;backgr...
问题:一个1920*900的大图,在1024*768的分辨率只能显示一部分,希望仍居中显示
解决方案CSS:
width: 100%;
background-position: 50% 50%;
示例code:
<style>
body {
background-repeat: no-repeat;
width: 100%;
background-position-x: 50%;
background-position-y: 118px;
background-image:url(@Url.Image("/XXX/XX.jpg"));
}
.book {
margin: 0 auto;
width: 960px;
height: 700px;
position: relative;
}
</style>
<div></div>