简体   繁体   English

从左侧(而不是右侧)剪切图片的宽度

[英]Cut the width of a picture from left, instead of right

I have a picture like this 我有这样的照片 在此处输入图片说明

Now, i want to implement something like a progress bar so this picture should start from a really short one and becomes longer and longer. 现在,我想实现类似进度条的功能,因此该图片应从非常短的图片开始,然后越来越长。

I am placing it as a background image in a div now. 我现在将其作为背景图像放置在div中。 Right now if i set up a width (like 300), the right side arrow will be cut off. 现在,如果我设置宽度(例如300),则右侧箭头将被切除。 Is there anyway I can do that so only the left side will be cut instead of the right? 无论如何,我能做到这一点,所以只会切掉左侧而不是右侧?

Thanks so much! 非常感谢!

you need to specify the position of the background image in your css 您需要在CSS中指定背景图片的位置

HTML 的HTML

<div class="progress-bar">
    <div class="progress-bar-image"></div>
</div>

CSS 的CSS

.progress-bar {width:100%; height:40px}
.progress-bar-image { background: url('http://i.stack.imgur.com/yWm8U.png') top right no-repeat; width:100px; height:30px;}

See jsfiddle jsfiddle

Use css background-position: 使用CSS背景位置:

.yourClassName
{ 
    background-image:url('your-image');
    background-repeat:no-repeat;
    background-attachment:fixed;
    background-position:right; 
}

and then size the element regularly. 然后定期调整元素的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM