css - 使用 CSS3 的梯形阴影

标签 css css-shapes

我想知道,有没有办法在下面的图像上创建阴影链接(可能使用伪类?)

enter image description here

灰色框后面的红色部分表示是梯形阴影,没有模糊。

现在想一想是否可行?

提前感谢您的帮助。

最佳答案

DEMO 1:

HTML:

<figure></figure>

CSS:

   figure{
        width:150px;
        height:150px;
        margin:50px auto;
        background:#ccc;
        position:relative;
        box-shadow: 0 14px 0 -10px red;
    }
    figure:before, figure:after{
        content:'';
        position:absolute;
        top: 2px;
        width:0;
        height:0;
    }

    figure:before{
        left: -5px;
        border-left: 5px solid transparent;
        border-right: 0px solid transparent;
        border-top: 77px solid red;
    }

    figure:after{
        right: -5px;
        border-left: 0px solid transparent;
        border-right: 5px solid transparent;
        border-top: 77px solid red;
    }

enter image description here

DEMO 2

figure{
    width:150px;
    height:150px;
    margin:50px auto;
    background:#ccc;
    position:relative;
    box-shadow: 0 12px 0 -10px red;
}
figure:before{
    content:'';
    position:absolute;
    top: -10px;
    left: 0;
    width:100%;
    height:100%;
    background:red;
    z-index: -1;
    -webkit-transform-style: preserve-3d;
    -webkit-transform: perspective(800) rotateX(-40deg);
}

关于css - 使用 CSS3 的梯形阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25692442/

相关文章:

javascript - 在 Javascript/CSS 中实现图标变形动画?

css - 有没有办法创建一个带有渐变和圆 Angular 边框的按钮(或 div)?

css - 顶部内部透明箭头

Javascript - 在 Canvas 上方放置一个 html 元素

html - webkit-溢出-滚动 : touch; orientation change issue

jquery - 我需要 CSS 中的玻璃形状

CSS 三 Angular 形被剪掉

php - 使用 PHP 使用 MySQL 数据填充 HTML 表

python - 如何通过 Markdown 在 Pelican 中使用 Pygments?

html - 需要光标停留在下拉菜单的主要元素上