此图像我用于制作3个方向的动画。 我只需要显示此图像的第一个字符。我正在使用背景位置 -
background-position:0px 200px;
但它在这里显示完整的图像。
样式
position:absolute;
top: 40px;left: 40px;
background-position: 0px 200px;
图像 -
请引导我通过Js小提琴。 Fiddle
答案 0 :(得分:2)
试试这个
img{
clip:rect(0px,300px,auto,0px);
position:absolute;
}
答案 1 :(得分:1)
您正在使用img
但background-position
属性不适用于img
元素,您需要在CSS中使用background-image
属性并需要设置元素的宽度这里,如果字符宽度在100px
左右,高度为200px
,则分别设置为height
和width
为200px
和100px
<div></div>
div {
height: 200px;
width: 100px;
background-image: url();
background-position: ;
background-repeat: no-repeat;
/* Other styles goes here */
}
答案 2 :(得分:1)
答案 3 :(得分:1)
请参阅此链接,希望这对您有所帮助:http://jsfiddle.net/9RYph/7/
div {
top: 40px;left: 40px;
background-size:100%;
background:url('http://i.stack.imgur.com/PuAjg.jpg');
width: 50%;
height: 600px;
}
答案 4 :(得分:0)
您需要在#character
ID:
background: url(http://img391.imageshack.us/img391/432/scorpionortholp0.jpg)
然后添加width
和height
属性以满足您的需求。