这个CSS3怎么了?我找不到它。

4
我已经创建了一个带有一些效果的按钮。当我在浏览器中进行测试时,只有在Mozilla浏览器中正常工作。我无法确定为什么它不能在-webkit-浏览器中工作。有人能告诉我为什么这段代码不起作用吗?请检查这个fiddle:http://jsfiddle.net/sarfarazdesigner/Qtw3x/ 以下是html代码:
<button name="feat-btn" id="feat-btn" class="push-button" type="submit">
    <span>Submit</span>
</button>

这里是 CSS。
.push-button {
    background: none repeat scroll 0 0 transparent;
    border: medium none;
    color: #FFFFFF;
    cursor: pointer;
    display: inline-block;
    font-size: 18px;
    padding: 0;
    text-align: center;
    text-decoration: none;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.push-button span:after {
    -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    border-color: #357536 transparent -moz-use-text-color;
    border-image: none;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-style: solid solid none;
    border-width: 5px 5px 0;
    content: "";
    display: block;
    margin: 0 -1.7em;
    overflow: hidden;
    text-indent: -9999px;
}
.push-button span:before {
    border-radius: 8px 8px 8px 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    content: ".";
    display: block;
    height: 55px;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: -1;
}
.push-button span {
    background-color: #4FB051;
    border-bottom: 1px solid #6FBE70;
    display: inline-block;
    height: 49px;
    line-height: 50px;
    margin-bottom: 5px;
    min-width: 110px;
    padding: 0 1.7em;
    position: relative;
}
.push-button:hover  span{background-color:#52a853;}

先在mozilla中检查它,然后您就会明白它将如何显示,或者您可以查看下面的图像。

这是在mozilla中查看的样子:

enter image description here

这是在Webkit浏览器中查看的样子:

enter image description here

你为什么在按钮里面使用 span 标签?而不是直接将文本放在开头和结尾的 button 标签之间? - zuallauz
1
@zuallauz 用于实现类似于3D效果的渲染。 - The Mechanic
1
更重要的是,为什么您要使用非标准的边框颜色属性? - BoltClock
2个回答

5

.push-button span:after选择器中,你的border-color出现了一些奇怪的问题。

border-color: #357536 transparent -moz-use-text-color;

只需将其更改为 #357537

jsFiddle

border-color: #357536;

我在进行该更改时,Chrome和Firefox都可以正常工作。


2
补充一下Daniel的回答:-moz-use-text-color似乎导致了你的样式出现问题。无论如何,你都不应该使用它,因为它已经被弃用了。改用currentColor代替,这样在Chrome上就不会出现问题了。 - Vimal Stan
@Vimal Stan:一开始就没有打算在Web样式表中使用它... - BoltClock

2

删除

   transparent -moz-use-text-color 

来自这一行

   border-color: #357536 transparent -moz-use-text-color;

我没有看到任何变化,但是运行正常。 结果是:
  border-color: #357536;

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接