CSS自定义&#39;提交&#39;按钮与<a href=""></a>按钮

时间:2014-06-27 18:17:08

标签: html css input form-submit appearance

我遇到了问题。这两个按钮的CSS代码是相同的,但外观完全不同。我无法得到:悬停或:主动工作。

我试图让左边的'input type =“submit'按钮看起来就像'a href =”“'按钮。有什么想法吗?

JSFiddle上的代码示例问题 http://jsfiddle.net/aL6M6/7/

对于 .button-big 和。按钮 - 大提交

,css完全相同

谢谢!

    .button-big
{
    display: inline-block;
    background: #ed391b;
    color: #fff;
    text-decoration: none;
    font-size: 1.75em;
    font-weight: 300;
    padding: 15px 45px 15px 45px;
    outline: 0;
    border-radius: 10px;
    box-shadow: inset 0px 0px 0px 1px rgba(0,0,0,0.75), inset 0px 2px 0px 0px rgba(255,192,192,0.5), inset 0px 0px 0px 2px rgba(255,96,96,0.85), 3px 3px 3px 1px rgba(0,0,0,0.15);
    background-image: -moz-linear-gradient(top, #ed391b, #ce1a00);
    background-image: -webkit-linear-gradient(top, #ed391b, #ce1a00);
    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ed391b), to(#ce1a00));
    background-image: -ms-linear-gradient(top, #ed391b, #ce1a00);
    background-image: -o-linear-gradient(top, #ed391b, #ce1a00);
    background-image: linear-gradient(top, #ed391b, #ce1a00);
    text-shadow: -1px -1px 1px rgba(0,0,0,0.5);
}

.button-big:hover
{
    background: #fd492b;
    box-shadow: inset 0px 0px 0px 1px rgba(0,0,0,0.75), inset 0px 2px 0px 0px rgba(255,192,192,0.5), inset 0px 0px 0px 2px rgba(255,96,96,0.85), 3px 3px 3px 1px rgba(0,0,0,0.15);
    background-image: -moz-linear-gradient(top, #fd492b, #de2a10);
    background-image: -webkit-linear-gradient(top, #fd492b, #de2a10);
    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fd492b), to(#de2a10));
    background-image: -ms-linear-gradient(top, #fd492b, #de2a10);
    background-image: -o-linear-gradient(top, #fd492b, #de2a10);
    background-image: linear-gradient(top, #fd492b, #de2a10);
    text-decoration: none;
}

.button-big:active
{
    background: #ce1a00;
    box-shadow: inset 0px 0px 0px 1px rgba(0,0,0,0.75), inset 0px 2px 0px 0px rgba(255,192,192,0.5), inset 0px 0px 0px 2px rgba(255,96,96,0.85), 3px 3px 3px 1px rgba(0,0,0,0.15);
    background-image: -moz-linear-gradient(top, #ce1a00, #ed391b);
    background-image: -webkit-linear-gradient(top, #ce1a00, #ed391b);
    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ce1a00), to(#ed391b));
    background-image: -ms-linear-gradient(top, #ce1a00, #ed391b);
    background-image: -o-linear-gradient(top, #ce1a00, #ed391b);
    background-image: linear-gradient(top, #ce1a00, #ed391b);
}

3 个答案:

答案 0 :(得分:3)

首先,如果它们应该是相同的,为什么要创建2种不同的样式?

我在开头放了一个CSS重置并将输入更改为按钮。它现在几乎相同,也许修改线高。 无论如何,我帮助了你http://jsfiddle.net/aL6M6/9/

的一半
    border: none;

答案 1 :(得分:1)

我在 CSS

中添加了这些修改
.button-big-submit {
    display: inline-block;
    background: #ed391b;
    color: #fff;
    text-decoration: none;
    font-size: 1.75em;
    line-height: normal;
    font-weight: 300;
    padding: 5px 15px 5px 15px;
    outline: 0;
    border: 0;  /* here */
    padding: 10px 40px; /*here*/
    border-radius: 10px;
    box-shadow: inset 0px 0px 0px 1px rgba(0, 0, 0, 0.75), inset 0px 2px 0px 0px rgba(255, 192, 192, 0.5), inset 0px 0px 0px 2px rgba(255, 96, 96, 0.85), 3px 3px 3px 1px rgba(0, 0, 0, 0.15);
    background-image: -moz-linear-gradient(top, #ed391b, #ce1a00);
    background-image: -webkit-linear-gradient(top, #ed391b, #ce1a00);
    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ed391b), to(#ce1a00));
    background-image: -ms-linear-gradient(top, #ed391b, #ce1a00);
    background-image: -o-linear-gradient(top, #ed391b, #ce1a00);
    background-image: linear-gradient(top, #ed391b, #ce1a00);
    text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.5);
}

然后,修复了.button-big-submit:hover上的拼写错误并添加了cursor: pointer;

更新了小提琴: http://jsfiddle.net/aL6M6/12/

答案 2 :(得分:1)

我发现了四个问题。

  1. 您需要禁用边框。 border:none;
  2. 你的.button-big-sumbit中有一个拼写错误:悬停(这就是为什么悬停不起作用)
  3. 你的填充.button-big和.button-big-submit是不同的。
  4. 您为所有输入设置了一些样式。
  5. 这是一个工作版本:fiddle

    @import url(http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:400,300,200);
    
    body {
        /*background: #D4D9DD url('images/bg03.jpg');*/
        background: #31393c url('images/bg04.jpg');
    }
    
    body, input, textarea, select {
        color: #373f42;
        font-size: 1.125em;
        font-family: 'Yanone Kaffeesatz', Tahoma, Arial, Sans-serif;
        /*      font-family: 'yanone_kaffeesatzlight';
        */
        line-height: 1.85em;
        font-weight: 300;
    }
    
    .button-big {
        cursor: pointer;
        display: inline-block;
        background: #ed391b;
        color: #fff;
        text-decoration: none;
        font-size: 1.75em;
        font-weight: 300;
        line-height : 1em;
        font-family: inherit;
        border: none;
        padding: 15px 45px 15px 45px;
        outline: 0;
        border-radius: 10px;
        box-shadow: inset 0px 0px 0px 1px rgba(0, 0, 0, 0.75), inset 0px 2px 0px 0px rgba(255, 192, 192, 0.5), inset 0px 0px 0px 2px rgba(255, 96, 96, 0.85), 3px 3px 3px 1px rgba(0, 0, 0, 0.15);
        background-image: -moz-linear-gradient(top, #ed391b, #ce1a00);
        background-image: -webkit-linear-gradient(top, #ed391b, #ce1a00);
        background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ed391b), to(#ce1a00));
        background-image: -ms-linear-gradient(top, #ed391b, #ce1a00);
        background-image: -o-linear-gradient(top, #ed391b, #ce1a00);
        background-image: linear-gradient(top, #ed391b, #ce1a00);
        text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.5);
    }
    
    .button-big:hover {
        background: #fd492b;
        box-shadow: inset 0px 0px 0px 1px rgba(0, 0, 0, 0.75), inset 0px 2px 0px 0px rgba(255, 192, 192, 0.5), inset 0px 0px 0px 2px rgba(255, 96, 96, 0.85), 3px 3px 3px 1px rgba(0, 0, 0, 0.15);
        background-image: -moz-linear-gradient(top, #fd492b, #de2a10);
        background-image: -webkit-linear-gradient(top, #fd492b, #de2a10);
        background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fd492b), to(#de2a10));
        background-image: -ms-linear-gradient(top, #fd492b, #de2a10);
        background-image: -o-linear-gradient(top, #fd492b, #de2a10);
        background-image: linear-gradient(top, #fd492b, #de2a10);
        text-decoration: none;
    }
    
    .button-big:active {
        background: #ce1a00;
        box-shadow: inset 0px 0px 0px 1px rgba(0, 0, 0, 0.75), inset 0px 2px 0px 0px rgba(255, 192, 192, 0.5), inset 0px 0px 0px 2px rgba(255, 96, 96, 0.85), 3px 3px 3px 1px rgba(0, 0, 0, 0.15);
        background-image: -moz-linear-gradient(top, #ce1a00, #ed391b);
        background-image: -webkit-linear-gradient(top, #ce1a00, #ed391b);
        background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#ce1a00), to(#ed391b));
        background-image: -ms-linear-gradient(top, #ce1a00, #ed391b);
        background-image: -o-linear-gradient(top, #ce1a00, #ed391b);
        background-image: linear-gradient(top, #ce1a00, #ed391b);
    }