css after和before选择器使用代码实例

快乐打工仔 分类:实例代码

下面分享一个关于after和before伪对象选择器使用的代码实例。

代码实例如下:

<!<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<title>前端教程网</title>
<style>
.tip{
  padding:5px 10px; 
  margin-left:15px; 
  border:1px solid #F8D19F; 
  border-radius:3px; 
  background-color:#FDFBB8; 
  color:#D07807; 
  font-size:12px; 
  position:absolute;
}
.tip:before,  .tip:after{
  content:attr(data-content); 
  font-family:xms; 
  position:absolute; 
  top:6px;
}
.tip:before, .tip before{
  color:#F8D19F; 
  left:-10px;
}
.tip:after, .tip after{
  color:#FDFBB8; 
  left:-8px;
}
</style>
<script type="text/javascript">
</script>
</head>
<body>
<img src="demo/CSS/img/F22.jpg" />
<span id="tip" class="tip" data-content="◀">前端教程网欢迎您</span>
</body>
</html>

上面的代码实现了再矩形一侧形成一个小箭头的功能,也就是带有箭头的tip效果。

回复

我来回复
  • 暂无回复内容