纯 CSS 实现漂亮的大标题效果

简单的代码,通过特定的组合,往往能带给人意想不到的效果~

复古风格

QQ截图20190513143614.png

  • 实现代码:
  1. .vintage {  
  2.     background: #EEE url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAHklEQVQImWNkYGBgYGD4//8/A5wF5SBYyAr+//8PAPOCFO0Q2zq7AAAAAElFTkSuQmCC) repeat;  
  3.     text-shadow: 5px -5px black, 4px -4px white;  
  4.     font-weight: bold;  
  5.     -webkit-text-fill-color: transparent;  
  6.     -webkit-background-clip: text;  
  7. }  

空心文字

QQ截图20190513143940.png

  • 实现代码:
  1. .stroke{  
  2.     color: transparent;  
  3.     -webkit-text-stroke: 1px black;  
  4.     letter-spacing: 0.04em;  
  5. }  

内阴影文字

QQ截图20190513144114.png

  • 实现代码:
  1. .press {  
  2.     color: transparent;  
  3.     background-color: black;  
  4.     text-shadow: rgba(255,255,255,0.5) 0 5px 6px, rgba(255,255,255,0.2) 1px 3px 3px;  
  5.     -webkit-background-clip: text;  
  6. }  

3D效果文字

QQ截图20190513144314.png

  • 实现代码:
  1. .threed{  
  2.     color: #fafafa;  
  3.     letter-spacing: 0;  
  4.     text-shadow: 0px 1px 0px #999, 0px 2px 0px #888, 0px 3px 0px #777, 0px 4px 0px #666, 0px 5px 0px #555, 0px 6px 0px #444, 0px 7px 0px #333, 0px 8px 7px #001135;  
  5. }  

如何在HTML里面调用呢?

直接上代码(o(* ̄︶ ̄*)o)

<html>
<head>
<style type="text/css">
.vintage {
background: #EEE url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAAAmkwkpAAAAHklEQVQImWNkYGBgYGD4//8/A5wF5SBYyAr+//8PAPOCFO0Q2zq7AAAAAElFTkSuQmCC) repeat;
text-shadow: 5px -5px black, 4px -4px white;
font-weight: bold;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
font-size: 100px;
}
.stroke{
color: transparent;
-webkit-text-stroke: 1px black;
letter-spacing: 0.04em;
font-size: 100px;
}
.press {
color: transparent;
background-color: black;
text-shadow: rgba(255,255,255,0.5) 0 5px 6px, rgba(255,255,255,0.2) 1px 3px 3px;
-webkit-background-clip: text;
font-size: 100px;
}
.threed{
color: #fafafa;
letter-spacing: 0;
text-shadow: 0px 1px 0px #999, 0px 2px 0px #888, 0px 3px 0px #777, 0px 4px 0px #666, 0px 5px 0px #555, 0px 6px 0px #444, 0px 7px 0px #333, 0px 8px 7px #001135;
font-size: 100px;
}
</style>
</head>
<body>
<div class="vintage" >卡酷建站</div>
<div class="stroke" >卡酷建站</div>
<div class="press" >卡酷建站</div>
<div class="threed" >卡酷建站</div>
</body>
</html>

发表评论 / Comment

用心评论~