CSS 邊框陰影立體邊框

螞蟻小編發表於2019-07-15

本章節分享一段程式碼例項,它使用CSS3實現了邊框陰影效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style>
.box-shadow {
  margin: 200px;
  height: 200px;
  width: 300px;
  text-align: center;
  line-height: 200px;
  background: white;
}
.box-shadow h3 {
  position: relative;
  text-align: center;
}
.effect {
  box-shadow: 0 1px 3px rgba(0,0,0,0.2),0 0 40px rgba(0,0,0,0.1) inset;
  -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.2),0 0 40px rgba(0,0,0,0.1) inset;
  -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.2),0 0 40px rgba(0,0,0,0.1) inset;
  position: relative;
  animation:;
}
.effect::after {
  content: "";
  height: 100px;
  width: 250px;
  margin: 0 auto;
  z-index: -1;
  position: absolute;
  left: 25px;
  bottom: 0;
  box-shadow: 0 0 20px rgba(0,0,0,0.6);
  -webkit-box-shadow: 0 0 20px rgba(0,0,0,0.6);
  -moz-box-shadow: 0 0 20px rgba(0,0,0,0.6);
  border-radius: 150px/10px;
}
</style>
</head>
<body>
  <div class="box-shadow effect">
    <h2>螞蟻部落</h2>
  </div>
</body>
</html>

相關閱讀:

(1).box-shadow屬性參閱CSS box-shadow一章節。

(2).border-radius參閱CSS border-radius一章節。

相關文章