简体   繁体   English

CSS梯形图像透明切

[英]css trapezoid image transparent cut

I want to make a trapezoid image with css. 我想用CSS制作梯形图像。 I've already found some code, but i want a code which makes the trapzeoid shape with transparent left border. 我已经找到了一些代码,但是我想要一个可以使梯形形状具有透明左边框的代码。

http://s28.postimg.org/ucfie0ctp/image.gif

So here you can see that, the left border of the image has been cut down. 因此,在这里您可以看到图像的左边框已被缩小。 I want to do that with css. 我想用CSS做到这一点。 Is it possible? 可能吗?

So i want to make the picture with the man. 所以我想和那个男人合影。 It is a simple picture and i want to cut down the left border. 这是一张简单的图片,我想减少左边框。 I tried this 我试过了

<div class="trapezoidImg"></div>
.trapezoidImg
{ 
    position: absolute;
    overflow: hidden; 
    padding: 0; 
    margin-left: 100px; 
    display: inline-block; 
    width:510px; 
    height:200px;
    background:url('http://iskolaujsag.blathy-bp.hu/wp-content/uploads/2009/04/getattachment-2.jpg');
    background-position: center; 
    -o-background-size: 510px; 
    -moz-background-size: 510px; 
    background-size: 510px;
}

.trapezoidImg:after
{
   content    : "";
   position   : absolute;
   z-index    : 2;
   left       : -50%;
   width      : 145%;
   height     : 80%;
   display    : block;
   background : rgb(51,51,59);   
    bottom: -90%;  
    -webkit-transform: rotate(55deg); 
    -moz-transform: rotate(55deg); 
    transform: rotate(53deg); 
}

and it works but the :after tag must have a color, i want a transparent one, but if i set it transparent, the image wont be cut. 并且它可以工作,但:after标记必须具有颜色,我想要一种透明的颜色,但是如果我将其设置为透明,则图像将不会被剪切。 And the reason why i dont want to edit the images in a photeditor, is its going to be a slider, and i dont want to edit all of the images. 而我之所以不想在光电探测器中编辑图像,是因为它将成为滑块,而且我也不想编辑所有图像。

Without any code and any tips of what you want to do in the end, i can go with this idea of gradient and image mixed in the background of a container. 最后没有任何代码和您想要做什么的任何提示,我可以将这种渐变和图像混合在容器背景中的想法付诸实践。

On each side some content ? 双方都有什么内容?

Here is a free interpretation of your unclear question , hopping it will make you give us some info usable. 这是对您不清楚的问题的免费解释,希望您能给我们一些有用的信息。

background: 
    url(http://i.stack.imgur.com/WJ3MT.png)   center  no-repeat,
    linear-gradient(47deg, tomato 50.1%, transparent 50%) left no-repeat,
    linear-gradient(47deg, transparent 50%, #333 50.1%) right no-repeat;

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

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