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;
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM