before css 旋转_在纯CSS中旋转的图像后面的纯背景

Is there a way i can draw the black "background" behind the image using pure CSS ?

I am persuaded that it can be done using the :before pseudo-class. But i can't make it work. I have also tried using shadows, but the final result is not similar what i am trying to achieve.

Scope and requirements:

Modern browsers, no javascript, no jQuery, no plugins and no extra HTML markup.

Before answering:

I know there are zillion ways to achieve what i am trying to do, however i am really looking forward for a pure CSS solution. As stated before, trying to avoid extra markup and javascript for something as simple as that. Thanks!

Here is a fiddle and the code below.

img {

position: absolute;

top: 100px;

left: 100px;

-webkit-transform-origin: center left;

-moz-transform-origin: center left;

-ms-transform-origin: center left;

-o-transform-origin: center left;

transform-origin: center left;

-webkit-transform: rotate(-2deg);

-moz-transform: rotate(-2deg);

-ms-transform: rotate(-2deg);

-o-transform: rotate(-2deg);

transform: rotate(-2deg);

}

img:before {

background: #000;

-webkit-transform-origin: center left;

-moz-transform-origin: center left;

-ms-transform-origin: center left;

-o-transform-origin: center left;

transform-origin: center left;

-webkit-transform: rotate(-4deg);

-moz-transform: rotate(-4deg);

-ms-transform: rotate(-4deg);

-o-transform: rotate(-4deg);

transform: rotate(-4deg);

width: 300px;

height: 300px;

content: ".";

}

解决方案

It seems like the before: element is ignored on img tags - http://jsfiddle.net/GVdYe/

Added a div (sorry :-)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值