CSS3 文字立體翻轉效果

admin發表於2017-05-04

分享一段程式碼例項,它實現了滑鼠懸浮,文字能夠實現立體翻轉效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
*{
  margin: 0;
  padding: 0;
}
body{
  background-color: #cccccc;
}
.box{
  width: 600px;
  margin: 100px auto;
}
span{
  display: inline-block;
  width: 100px;
  height: 100px;
  font-size: 100px;
  font-family: 'microsoft yahei';
  margin-right: 40px;
  float: left;
  position: relative;
}
span::before,
span::after{
  content:attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  color: rgba(0,0,0,.3);
  transform-origin: left center;
  transform: scale(0.95,1);
  transition: transform 0.5s;
}
span::after{
  color: #ffffff;
}
div:hover span::after{
  transform: rotateY(40deg) skew(0deg,10deg) scale(0.95,1);
}
div:hover span::before{
  transform: skew(0deg,25deg) scale(0.95,1);
}
</style>
</head>
<body>
<div class="box">
  <span data-text="螞">螞</span>
  <span data-text="蟻">蟻</span>
  <span data-text="部">部</span>
  <span data-text="落">落</span>
</div>
</body>
</html>

相關文章