使用CSS为IE设置样式提交按钮

时间:2011-01-16 08:05:13

标签: css internet-explorer selector

对于Firefox,Chrome input[type=button]:hover,input[type=submit]:hoverinput[type=button],input[type=submit]将完成这项工作,但如何处理IE(8)?

@Herohtar: 他们是这样?怎么样?我使用这个CSS并且他们不会工作:

    input[type=button],input[type=submit]
{
    border-right-color: black;
    border-right-style: solid;
    border-right-width: 1px;
    border-left-color: black;
    border-left-style: solid;
    border-left-width: 1px;
    border-bottom-color: black;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    border-top-color: black;
    border-top-style: solid;
    border-top-width: 1px;
    text-align: center;
    font-weight: bold;
    height: 30px;
    font-family: Georgia,'Times New Roman',times,serif;
    color: #000000;
    border-radius: 4px;
    -moz-border-radius:4px;
    -webkit-border-radius:4px;
    background: #fceabb; /* old browsers */
    background: -moz-linear-gradient(top, #fceabb 0%, #fccd4d 50%, #f8b500 51%, #fbdf93 100%); /* firefox */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fceabb), color-stop(50%,#fccd4d), color-stop(51%,#f8b500), color-stop(100%,#fbdf93)); /* webkit */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fceabb', endColorstr='#fbdf93',GradientType=0 ); /* ie */
}

input[type=button]:hover,input[type=submit]:hover
{
    color: black;   
    border-radius: 6px;
    -moz-border-radius:6px;
    -webkit-border-radius:6px;
    -khtml-border-radius:6px;
    background: #ffb76b; /* old browsers */
    background: -moz-linear-gradient(top, #ffb76b 0%, #ffa73d 50%, #ff7c00 51%, #ff7f04 100%); /* firefox */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffb76b), color-stop(50%,#ffa73d), color-stop(51%,#ff7c00), color-stop(100%,#ff7f04)); /* webkit */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffb76b', endColorstr='#ff7f04',GradientType=0 ); /* ie */
}

2 个答案:

答案 0 :(得分:7)

input[type=submit]input[type=button]都适用于IE8,以及:hover条件。

编辑:您在IE8中列出的CSS对我来说非常适合我:http://jsfiddle.net/dnZNE/您的CSS中的其他内容可能会覆盖它吗?

答案 1 :(得分:1)

如果可以使用jQuery(www.jquery.com):

$(':submit').css( 'attribute', 'value' );

如果不是,我担心你必须在这些按钮上添加课程。