css 如何使大图只显示中间部分
将图片设置成背景图
<div style="width: 100%;height: 400px;"> <div style=" width: 100%; height: 400px; background:url(img/banner.jpg) no-repeat 50%;background-size:200% 100%"></div> </div>
注意,第一个大盒子可以不设置宽和高,由内容(即第二个大盒子)撑开,但是第二个盒子必须设置高
将图片设置成背景图
<div style="width: 100%;height: 400px;"> <div style=" width: 100%; height: 400px; background:url(img/banner.jpg) no-repeat 50%;background-size:200% 100%"></div> </div>
注意,第一个大盒子可以不设置宽和高,由内容(即第二个大盒子)撑开,但是第二个盒子必须设置高