用图片定位html背景

来源:互联网 发布:java并发最好的书籍 编辑:程序博客网 时间:2024/05/16 11:24
background:url(../images/pub_goods.png) no-repeat;//引入图片路径,图片不重复显示
background-size: auto 200px;//将背景图片压缩为200px,比如原图的图标尺寸一般会比较大,这时就需要用到background-size参数缩小图片
background-position:0px -110px;//定位当前元素的背景图片,第一个参数为x横坐标,第二个参数为y纵坐标,一般横纵坐标都是负数开始

贴代码

<div class="head-right">        <div class="more">        </div></div>//css代码.head-right {    width: 15%;    height: 45px;    float: left;}.more {    width: 100%;    float: right;    height: 45px;    background:url(../images/pub_goods.png) no-repeat;    background-size: auto 200px;    background-position:0 -110px;}
0 0