---
title: "大图片根据分辨率自适应宽度"
author: "mybwu_com"
date: "2014-10-28T18:24:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2014-10-31T17:14:10Z"
id: 2150219
url: "https://newbanlance.iteye.com/blog/2150219"
---

问题：一个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 class="book"></div>
```