【五分钟CSS】纯CSS光反射按钮效果

BGM:Hello Capitano – Broke In Summer

本期代码地址:https://fgpai.com/video/css
Github总合地址:https://github.com/FastChen/FiveMinutesCSSEffect
今天给大家分享一个纯CSS光反射按钮效果

本期代码

<!--
    代码来源于网络 Code from the Internet
    复古派科技:https://fgpai.com
    灵工艺软件工作室:https://nullcraft.org
    项目文件开源地址:https://github.com/FastChen/FiveMinutesCSSEffect
    单文件代码查看地址:https://fgpai.com/video/css
-->
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>五分钟玩转CSS - 纯CSS光反射按钮效果</title>
</head>
<style>
* {
  margin: 0;
  padding: 0;
}

html,body {
  box-sizing: border-box;
  height: 100%;
  width: 100%;
}

.buttons {
  display: flex;
  flex-direction: row;
      flex-wrap: wrap;
  justify-content: center;
  text-align: center;
  width: 100%;
  height: 100%;
  margin: 0 auto;
/*   padding: 2em 0em; */
}

.container {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding:  40px 0px;
  width: 240px;
}

h1 {
  text-align: left;
  color: #444;
  letter-spacing: 0.05em;
  margin: 0 0 0.4em;
  font-size: 1em;
}

p {
  text-align: left;
  color: #444;
  letter-spacing: 0.05em;
  font-size: 0.8em;
  margin: 0 0 2em;
}


.btn {
  letter-spacing: 0.1em;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  line-height: 45px;
  max-width: 160px;
  position: relative;
  text-decoration: none;
  text-transform: uppercase;
  width: 100%;
}
.btn:hover {
  text-decoration: none;
}

/*btn_background*/
.effect {
  color: #FFF;
  border: 4px solid #000;
  box-shadow:0px 0px 0px 1px #000 inset;
  background-color: #000;
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease-in-out;
}
.effect:hover {
  border: 4px solid #666;
  background-color: #FFF;
  box-shadow:0px 0px 0px 4px #EEE inset;
}

/*btn_text*/
.effect span {
  transition: all 0.2s ease-out;
  z-index: 2;
}
.effect:hover span{
  letter-spacing: 0.13em;
  color: #333;
}

/*highlight*/
.effect:after {
  background: #FFF;
  border: 0px solid #000;
  content: "";
  height: 155px;
  left: -75px;
  opacity: .8;
  position: absolute;
  top: -50px;
  -webkit-transform: rotate(35deg);
          transform: rotate(35deg);
  width: 50px;
  transition: all 1s cubic-bezier(0.075, 0.82, 0.165, 1);/*easeOutCirc*/
  z-index: 1;
}
.effect:hover:after {
  background: #FFF;
  border: 20px solid #000;
  opacity: 0;
  left: 120%;
  -webkit-transform: rotate(40deg);
          transform: rotate(40deg);
}
</style>
<body>
<div class="buttons">
  <div class="container">
      <h1>光反射</h1>
      <p>Light reflection</p>
      <a href="#" class="btn effect"><span>Hover</span></a>
  </div>
</div>

</body>
</html>

本视频由 复古派科技 官方制作 你可以前往 官方B站 获取更多教程

发表评论

登录后才能评论