下面是一组查看更多的css样式炫酷效果,主要利用的是scss的混入语法、css3的过渡动画以及CSS中用于定义贝塞尔曲线的函数
cubic-bezier(0.65, 0, 0.076, 1)
P1x是 0.65,表示曲线的第一个控制点的 x 坐标。P1y是 0,表示曲线的第一个控制点的 y 坐标。P2x是 0.076,表示曲线的第二个控制点的 x 坐标。P2y是 1,表示曲线的第二个控制点的 y 坐标。
<template>
<div id="container">
<button class="learn-more">
<span class="circle" aria-hidden="true">
<span class="icon arrow"></span>
</span>
<span class="button-text">Learn More</span>
</button>
</div>
</template>
<script>
export default {
data() {
return {}
},
methods: {},
}
</script>
<style scoped lang="scss">
$bg: #f3f8fa;
$white: #fff;
$black: #282936;
@mixin transition(
$property: all,
$duration: 0.45s,
$ease: cubic-bezier(0.65, 0, 0.076, 1)
) {
transition: $property $duration $ease;
}
* {
box-sizing: border-box;
&::before,
&::after {
box-sizing: border-box;
}
}
button {
position: relative;
display: inline-block;
cursor: pointer;
outline: none;
border: 0;
vertical-align: middle;
text-decoration: none;
background: transparent;
padding: 0;
font-size: inherit;
font-family: inherit;
&.learn-more {
width: 160px;
height: auto;
.circle {
@include transition(all, 0.45s, cubic-bezier(0.65, 0, 0.076, 1));
position: relative;
display: block;
margin: 0;
width: 35px;
height: 35px;
background: $black;
border-radius: 26px;
.icon {
@include transition(all, 0.45s, cubic-bezier(0.65, 0, 0.076, 1));
position: absolute;
top: 0;
bottom: 0;
margin: auto;
background: $white;
&.arrow {
@include transition(all, 0.45s, cubic-bezier(0.65, 0, 0.076, 1));
left: 5px;
width: 18px;
height: 2px;
background: none;
&::before {
position: absolute;
content: '';
top: -4px;
right: 1px;
width: 10px;
height: 10px;
border-top: 2px solid #fff;
border-right: 2px solid #fff;
transform: rotate(45deg);
}
}
}
}
.button-text {
@include transition(all, 0.45s, cubic-bezier(0.65, 0, 0.076, 1));
position: absolute;
top: -4px;
left: 0;
right: 0;
bottom: 0;
padding: 10px 0;
margin: 0 0 0 35px;
color: $black;
font-weight: 700;
text-align: center;
text-transform: uppercase;
}
}
&:hover {
.circle {
width: 100%;
.icon {
&.arrow {
background: $white;
transform: translate(16px, 0);
}
}
}
.button-text {
color: $white;
}
}
}
@supports (display: grid) {
body {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 10px;
grid-template-areas: '. main main .' '. main main .';
}
#container {
grid-area: main;
align-self: center;
justify-self: center;
}
}
</style>