css半透明邊框程式碼例項

antzone發表於2017-04-03

分享一段程式碼例項,它實現了邊框透明效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
.box {
  width: 200px;
  height: 200px;
  float: left;
  padding: 10px;
  margin: 10px 20px;
  color: #333;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
}
.box.opacityBorder {
  background-color:green;
  background-size: 100% 100%;
  overflow: hidden;
}
.box.opacityBorder>div {
  margin: 25px;
  width: 150px;
  height: 150px;
  border: 10px solid hsla(0, 0%, 100%, .5);
  background: white;
  background-clip: padding-box;
}
</style>
</head>
<body>
  <div class="box opacityBorder">
    <div class=""> </div>
  </div>
</body>
</html>

相關文章