1

我想从三个图像创建按钮。我使用具有多个背景的 CSS3。

我需要这个:

http://i.stack.imgur.com/LxyIQ.png

但我明白了:

http://i.stack.imgur.com/5vUHz.png

这是我的代码:

a.activemenu
{
font-family:"Arial",Arial, serif;
font-size:25px;
text-align:center;
text-decoration:none;
color:white;
background-image:url("buttonleft.png"),url("buttonmid.png"),url("buttonright.png");
background-repeat:no-repeat,repeat-x,no-repeat;
padding:0 33px 62px 33px;
}

我可能做错了什么?

4

3 回答 3

1

试试这个:

background: url(buttonleft.png) left bottom no-repeat, 
            url(buttonmid.png) left bottom repeat-x, 
            url(buttonright.png) right bottom no-repeat;

参考。http://www.css3.info/preview/multiple-backgrounds/

于 2013-09-10T17:21:59.063 回答
1

我只使用没有图像的 css 创建了这个按钮。

    a.activemenu {
background: #931e5b; /* Old browsers */
background: -moz-linear-gradient(top, #931e5b 0%, #3c0c25 100%); /* FF3.6+ */
background:A -webkit-gradient(linear, left top, left bottom, colorQ-stop(0%,#931e5b), color-stop(100%,#3c0c25)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #931e5b 0%,#3c0c25 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #931e5b 0%,#3c0c25 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #931e5b 0%,#3c0c25 100%); /* IE10+ */
background: linear-gradient(to bottom, #931e5b 0%,#3c0c25 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#931e5b', endColorstr='#3c0c25',GradientType=0 ); /* IE6-9 */
    border:0px;
    font-family:"Arial",Arial, serif;
font-size:25px;
text-align:center;
padding:10px;
    border-radius: 0px 0px 10px 10px;
    color:#fff;
    text-decoration:none;
}

http://jsfiddle.net/parslook/LhMWn/2/

于 2013-09-10T17:26:17.267 回答
0

如果您使用的是 CSS3(如标签中所述),您可以通过使用一些渐变和边框半径来简化它。

a.activemenu {
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;

    font-family: arial, sans-serif;    
    color: #fff;
    text-decoration: none;
    text-align: center;

    padding: 10px 33px;

    background: #931e5b;
    background: -webkit-linear-gradient(bottom, #3e0c26, #931e5b);
    background: -moz-linear-gradient(bottom, #3e0c26, #931e5b);
    background: -ms-linear-gradient(bottom, #3e0c26, #931e5b);
    background: -o-linear-gradient(bottom, #3e0c26, #931e5b);
    background: linear-gradient(bottom, #3e0c26, #931e5b);
}

看到这个小提琴:http: //jsfiddle.net/LcW6K/

于 2013-09-10T17:22:11.897 回答