加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

有背景梯度和图象的按钮使用html和css

发布时间:2020-12-14 23:23:38 所属栏目:资源 来源:网络整理
导读:我想要一个带有渐变背景和图像的按钮.这是我到目前为止: jsfiddle/D6xKD/ 如果您查看按钮,您可以看到渐变仅在图像周围而不是整个按钮. 注意:这个解决方案我从其他参考资料中获取了一个带有渐变背景和背景图像的按钮. 我的问题是:如何使梯度和图像适用于包
我想要一个带有渐变背景和图像的按钮.这是我到目前为止:

jsfiddle/D6xKD/

如果您查看按钮,您可以看到渐变仅在图像周围而不是整个按钮.

注意:这个解决方案我从其他参考资料中获取了一个带有渐变背景和背景图像的按钮.

我的问题是:如何使梯度和图像适用于包括ie7及以上的跨浏览器?

HTML:

<button class="button" onclick="submit();" type="button">Text button</button>

CSS:

.button{
    color: #FFFFFF;
    display: inline-block;
    font-family:Arial;
    font-size: 10px;
    font-weight: normal;
    padding: 9px 36px 9px 4px;
    text-decoration: none;
    margin:4px auto auto;
    cursor:pointer; 
    border:0px;
    background: #3ba93d;
    background-position: 66px 4px;
    background-repeat:no-repeat;
    background-image: url(http://goo.gl/mw5HWR); /* fallback */
    background-image: url(http://goo.gl/mw5HWR),-webkit-gradient(linear,left top,left bottom,from(#3ba93d),to(#27842a)); /* Saf4+,Chrome */
    background-image: url(http://goo.gl/mw5HWR),-webkit-linear-gradient(top,#3ba93d,#27842a); /* Chrome 10+,Saf5.1+ */
    background-image: url(http://goo.gl/mw5HWR),-moz-linear-gradient(top,#27842a); /* FF3.6+ */
    background-image: url(http://goo.gl/mw5HWR),-ms-linear-gradient(top,#27842a); /* IE10 */
    background-image: url(http://goo.gl/mw5HWR),-o-linear-gradient(top,#27842a); /* Opera 11.10+ */
    background-image: url(http://goo.gl/mw5HWR),linear-gradient(top,#27842a); /* W3C */
    }

提前致谢.

解决方法

可以尝试:
<button class="button" onclick="submit();" type="button">Text button <span></span></button>

        <style>
        .button{
            color: #FFFFFF;
            font-family:Arial;
            font-size: 10px;
            font-weight: normal;
            padding: 0;
            padding-left: 20px;
            height: 36px;
            width: 120px;
            margin:4px auto auto;
            text-align: left;
            cursor:pointer; 
            border:0px;
            background: #3ba93d;
            background-position: 66px 4px;
            background-repeat:no-repeat;
            background: #3ba93d; /* fallback */
            background: -webkit-gradient(linear,Chrome */
            background: -webkit-linear-gradient(top,Saf5.1+ */
            background: -moz-linear-gradient(top,#27842a); /* FF3.6+ */
            background: -ms-linear-gradient(top,#27842a); /* IE10 */
            background: -o-linear-gradient(top,#27842a); /* Opera 11.10+ */
            background: linear-gradient(top,#27842a); /* W3C */
            }
          .button span {
            position: absolute;
            top: 17px;
            left: 100px;
            width: 20px;
            height: 24px;
            background: url(http://goo.gl/mw5HWR);
          }
           </style>

JS Fiddle

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读