css问题!如何提取图片中的一部分

html-css010

css问题!如何提取图片中的一部分,第1张

用绝对定位..

background-position: -186px -22px 定位背景的具体位置..

比如你这个整体图, 是一张背景 , 你就可以通过 background-position:XX

来定位 这个张背景图的具体显示那块内容.. 可以去试试..网上很多素材

光靠字面理解很难,最好自己动手实践

方法一:

<div style="width:600pxheight:200pxbackground:url(路径图片中间部分切成1px宽) repeat-x">

<img src="路径图片左圆角" style="float:left"/>

<img src="路径图片右圆角" style="float:right"/>

</div>

方法二:

<div style="width:600pxheight:200pxbackground:url(图片中间部分切成1px宽)">

<div style="background:url(路径图片左圆角) no-repeatfloat:leftwidth:左圆角宽pxheight:左圆角高px">

<div style="background:url(路径图片右圆角) no-repeatfloat:rightwidth:右圆角宽pxheight:右圆角高px">

</div>

注:切图时,圆角图片一定要连着圆角外的白色部分一起切,中间填充部分可以只切1px宽,实际高度进行填充

background:url(pic.jpg) no-repeat left top

后面两个参数就是移动图片位置的,第一个是水平位置,如left或者right或者center,第2个是垂直位置,如top或者bottom或者center,也可以是数字,如

background:url(pic.jpg) no-repeat -10px -20px

具体看你要截取的位置