css 關閉按鈕實現


通過css的偽元素:before,:after以及transform: rotate(45deg);旋轉來實現(支持IE9及其以上版本)

<div class="close"></div>
/*關閉圖標*/

.close {
    position: absolute;
    right: -25px;
    top: -25px;
    width: 50px;
    height: 50px;
    background: silver;
    border-radius: 25px;
    box-shadow: 2px 2px 5px 0px black;
    cursor: pointer;
}

.close:hover {
    background: red;
}
.close:before {
    position: absolute;
    content: '';
    width: 30px;
    height: 10px;
    background: white;
    transform: rotate(45deg);
    top: 20px;
    left: 10px;
}
.close:after{
    content: '';
        position: absolute;
    width: 30px;
    height: 10px;
    background: white;
    transform: rotate(-45deg);
    top: 20px;
    left: 10px;
}

效果圖:

 


免責聲明!

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



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