Day14 互动式CSS按钮动画(上)

以下是以此图为例的互动式CSS按钮动画范例:

变深

HTML

<div class="shape-ex1">按钮</div>

CSS

.shape-ex1{
    width: 150px;
    height: 40px;
    display: block;
    text-align: center;
    cursor: pointer;
    line-height: 40px;
    color: #000;
    background-color: transparent;
    border: 1px solid #000;
    transition: all .3s linear;
}
.shape-ex1:hover{
    background-color: #000;
    color: #fff;
}

变浅

HTML

<div class="shape-ex2">按钮</div>

CSS

.shape-ex2{
    width: 150px;
    height: 40px;
    display: block;
    text-align: center;
    cursor: pointer;
    line-height: 40px;
    color: #fff;
    background-color: #000;
    transition: all .3s linear;
}
.shape-ex2:hover{
    background-color: #666;
}

由左向右填满

HTML

<div class="shape-ex3"><p>按钮</p></div>

CSS

.shape-ex3{
    width: 150px;
    height: 40px;
    display: block;
    text-align: center;
    cursor: pointer;
    line-height: 40px;
    color: #000;
    background-color: transparent;
    border: 1px solid #000;
    position: relative;
    transition: all .3s linear;
}
.shape-ex3 > p{
    position: relative;
    z-index: 1;
}
.shape-ex3::before{
    content: "";
    width: 0%;
    height: 100%;
    display: block;
    background-color: #000;
    position: absolute;
    top: 0;
    left: 0;
    transition: all .3s ease;
}
.shape-ex3:hover{
    color: #fff;
}
.shape-ex3:hover::before{
    width: 100%;
}

由右向左填满

HTML

<div class="shape-ex4"><p>按钮</p></div>

CSS

.shape-ex4{
    width: 150px;
    height: 40px;
    display: block;
    text-align: center;
    cursor: pointer;
    line-height: 40px;
    color: #000;
    background-color: transparent;
    border: 1px solid #000;
    position: relative;
    transition: all .3s linear;
}
.shape-ex4 > p{
    position: relative;
    z-index: 1;
}
.shape-ex4::before{
    content: "";
    width: 0%;
    height: 100%;
    display: block;
    background-color: #000;
    position: absolute;
    top: 0;
    right: 0;
    transition: all .3s ease;
}
.shape-ex4:hover{
    color: #fff;
}
.shape-ex4:hover::before{
    width: 100%;
}

由上向下填满

HTML

<div class="shape-ex5"><p>按钮</p></div>

CSS

.shape-ex5{
    width: 150px;
    height: 40px;
    display: block;
    text-align: center;
    cursor: pointer;
    line-height: 40px;
    color: #000;
    background-color: transparent;
    border: 1px solid #000;
    position: relative;
    transition: all .3s linear;
}
.shape-ex5 > p{
    position: relative;
    z-index: 1;
}
.shape-ex5::before{
    content: "";
    width: 100%;
    height: 0%;
    display: block;
    background-color: #000;
    position: absolute;
    top: 0;
    left: 0;
    transition: all .3s ease;
}
.shape-ex5:hover{
    color: #fff;
}
.shape-ex5:hover::before{
    height: 100%;
}

由下向上填满

HTML

<div class="shape-ex6"><p>按钮</p></div>

CSS

.shape-ex6{
    width: 150px;
    height: 40px;
    display: block;
    text-align: center;
    cursor: pointer;
    line-height: 40px;
    color: #000;
    background-color: transparent;
    border: 1px solid #000;
    position: relative;
    transition: all .3s linear;
}
.shape-ex6 > p{
    position: relative;
    z-index: 1;
}
.shape-ex6::before{
    content: "";
    width: 100%;
    height: 0%;
    display: block;
    background-color: #000;
    position: absolute;
    bottom: 0;
    left: 0;
    transition: all .3s ease;
}
.shape-ex6:hover{
    color: #fff;
}
.shape-ex6:hover::before{
    height: 100%;
}

<<:  认识CSS(三):CSS选择器

>>:  Day14 CSS基础设定_4

DAY6-EXCEL统计分析:计算连续型机率

上次学会了有关离散型的机率生活题 今天来说有关连续型的机率生活应用 NORMAL DISTRIBUT...

DAY29-ASP.NET网页切换导向及状态管理-趴水

ASP.NET网页切换导向及状态管理-趴水 今天来做做看 在网页输入资料後 按下按钮 可以将资料导向...

Unity与Photon的新手相遇旅途 | Day9-第三人称设定

今天的内容是该如何简单地做到第三人称视角 ...

[day-6] 在正式开始写程序之前,先来认识电脑本身吧!(Part .1)

前面 [day-5] 有基本介绍Hello World的用途 在我们正式开始写程序之前,先来认识一下...

[13th][Day23] visualization

docker 提供了提供了多个指令可以让我以 文字的 方式了解 image 但是... 人都是懒惰的...