码迷,mamicode.com
首页 > Web开发 > 详细

css中按钮的四种状态

时间:2017-12-08 01:15:47      阅读:17      评论:0      收藏:0      [点我收藏+]

标签:sub   鼠标悬停   鼠标   20px   out   settings   按钮   例子   css   

css中按钮有四种状态

1. 普通状态
2. hover 鼠标悬停状态
3. active 点击状态
4. focus 取得焦点状态

.btn:focus{outline:0;} 可以去除按钮或a标签点击后的蓝色边框

下面的例子中.btn1用focus按钮会按下,不弹起
      .btn2用active按钮点击按下,会弹起

<button class="btn btn1">Save Settings</button>
<button class="btn btn2">Submit</button>
.btn{
    appearance: none;
    background: #026aa7;
    color: #fff;
    font-size: 20px;
    padding: 0.65em 1em;
    border-radius: 4px;
    box-shadow: inset 0 -4px 0 0 rgba(0,0,0,0.2);
    margin-right: 1em;
    cursor: pointer;
    border:0;
}
.btn1:hover{
    box-shadow: inset 0 -4px 0 0 rgba(0,0,0,0.6), 0 0 8px 0 rgba(0,0,0,0.5);
}
.btn1:focus{
    position: relative;
    top: 4px;
    box-shadow: inset 0 3px 5px 0 rgba(0,0,0, 0.2);
    outline: 0;
}
.btn2:hover{
    box-shadow: inset 0 -4px 0 0 rgba(0,0,0,0.6), 0 0 8px 0 rgba(0,0,0,0.5);
}
.btn2:active{
    position: relative;
    top: 4px;
    box-shadow: inset 0 3px 5px 0 rgba(0,0,0,0.2);
    outline: 0;
}
.btn2:focus{
    outline: 0;
}

 

css中按钮的四种状态

标签:sub   鼠标悬停   鼠标   20px   out   settings   按钮   例子   css   

(0)
(0)
   
举报
评论 一句话评论(0
0条  
登录后才能评论!
© 2014 mamicode.com 版权所有 京ICP备13008772号-2
迷上了代码!