精通CSS 第五章 立体按钮

有效的链接变化

a:link,a:visited{color:red;}
a:hover,a:focus,a:active{color:blue;}
//顺序调换不起作用

简单按钮

  <style>
        p{margin: 5em;}
        a{ font-size: 30px;font-weight: 500;}
        a.button{
            display: block;
            width: 6.6em;
            line-height: 1.4;
            color: #ffffff;
            text-decoration: none;
            text-align: center;
           /*初始状态*/
            border: 1px solid #66a300;
            background-color: #8cca12;
      }
        /*鼠标浮动*/
        a.button:hover{
            background-color: #f7a300;
            border-color: #ff7400;
        }
        /*激活*/
        a.button:active{
            background-color: #a7a7a7;
            border-color: #868686;
        }
 </style>
    </head>
    <body>
        <p><a href="#" class="button">Book Now &raquo;</a></p>
    </body>

这里写图片描述
纯图片按钮

    <style>
        p{margin: 5em;}
        a{ font-size: 30px;font-weight: 500;}
        a.button{
            display: block;
            width: 202px;/*根据图片尺寸*/
            height: 72px;
            background: url("button.png");
      }
        /*鼠标浮动*/
        a.button:hover{
            background-image: url("button-over.png");
        }
        /*激活*/
        a.button:active{
            background-image: url("button-active.png");
        }
 </style>
    </head>
    <body>
        <p><a href="#" class="button"></a></p>
    </body>

这里写图片描述
大图片background-position做按钮

    <style>
        p{margin: 5em;}
        a{ font-size: 30px;font-weight: 500;}
        a.button{
            display: block;
            width: 203px;/*根据图片尺寸*/
            height: 72px;
            background:url("buttons.png") -203px 0 no-repeat;
            /*取大图片-203px位置 */
      }
        /*鼠标浮动*/
        a.button:hover{
           background-position: right top;
        }
        /*激活*/
        a.button:active{
           background-position: left top;
        }
    </style>
    </head>
    <body>
        <p><a href="#" class="button"></a></p>
    </body>

这里写图片描述
纯css做按钮

    <style>
    p{margin: 5em;}
    a{ font-size: 30px;font-weight: 500;}
    a.button{
        display: block;
        width: 6.6em;
        height: 1.4em;
        line-height: 1.4;
        text-align: center;
        text-decoration: none;
        font-weight: 600;
        border: 1px solid #66a300;
        color: white;
        background-color: #8cca12;
        /*描绘最初效果*/
        -webkit-border-radius: 6px;/*圆角*/
        -webkit-text-shadow: 2px 2px 2px #66a300;/*文字阴影*/
        -webkit-box-shadow: 2px 2px 2px #ccc;/*按钮阴影*/
        /*过渡*/
        background-image: -webkit-gradient(linear,left top,left bottom, from(#abe142),to(#67a400));
        /*翻转*/
        -webkit-box-reflect: below 2px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(0.62, transparent), to(white));

    }
    /*鼠标浮动*/
    a.button:hover{
        background-color: #f7a300;
        text-shadow: 2px 2px 2px #ff7400;
        border-color: #ff7400;
        background-image: -webkit-gradient(linear, left top, left bottom, from(#f7a300), to(#ff7400));
    }
    /*激活*/
    a.button:active{
        background-color: #a7a7a7;
        text-shadow: 2px 2px 2px #868686;
        border-color: #868686;
        background-image: -webkit-gradient(linear, left top, left bottom, from(#a7a7a7), to(#868686));
    }
</style>
</head>
<body>
    <p><a href="#" class="button">Book Now &raquo;</a></p>
</body>

这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值