本文介绍了有没有办法在一个元素上使用两个CSS3框阴影?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Photoshop模型中复制一个按钮样式,它有两个阴影。第一个阴影是内部较亮的盒子阴影(2px),第二个阴影是按钮外部的阴影(5px)本身。

I'm trying to replicate a button style in a Photoshop mock-up that has two shadows on it. The first shadow is an inner lighter box shadow (2px), and the second is a drop shadow outside the button (5px) itself.

在Photoshop这很容易 - 内阴影和阴影。在CSS中,我可以显然有一个或另一个,但不能同时两个。

In Photoshop this is easy - Inner Shadow and Drop Shadow. In CSS I can apparently have one or the other, but not both at the same time.

如果你在浏览器中尝试下面的代码,你会看到

If you try the code below in a browser, you'll see that the box-shadow overrides the inset box-shadow.

以下是插入框阴影:

box-shadow: inset 0 2px 0px #dcffa6;

这是我想要的按钮上的阴影:

And this is what I would like for the drop shadow on the button:

box-shadow: 0 2px 5px #000;

对于上下文,这里是我的全按钮代码(含渐变和全部):

For context, here's my full button code (with gradients and all):

button {
    outline: none;
    position: relative;
    width: 160px;
    height: 40px;
    font-family: 'Open Sans', sans-serif;
    color: #fff;
    font-weight: 800;
    font-size: 12px;
    text-shadow: 0px 1px 3px black; 
    border-radius: 3px;
    background-color: #669900;
    background: -webkit-gradient(linear, left top, left bottom, from(#97cb52), to(#669900));
    background: -moz-linear-gradient(top, #97cb52, #669900);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#97cb52', endColorstr='#669900');
    box-shadow: inset 0 2px 0px #dcffa6;
    box-shadow: 0 2px 5px #000;
    border: 1px solid #222;
    cursor: pointer;
}


推荐答案

box-shadow: inset 0 2px 0px #dcffa6, 0 2px 5px #000;

这篇关于有没有办法在一个元素上使用两个CSS3框阴影?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 02:40