css 实现关闭按钮 X

.close::before {
  content: "\2716";
}

然后就显示出来了

 

这里有个更直接的例子

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<style>
  .close {
    background: orange;
    color: red;
    border-radius: 12px;
    line-height: 20px;
    text-align: center;
    height: 20px;
    width: 20px;
    font-size: 18px;
    padding: 1px;
    top: -10px;
    right: -10px;
    position: absolute;
}
/* use cross as close button */
.close::before {
    content: "\2716";
}
</style>
<body>
  <div style="height: 100px; width: 100px; border: 1px solid black; position: relative;">
    <span class="close"></span>
</div>
</body>
</html>

  

posted on 2017-05-24 10:10  _jackie  阅读(23394)  评论(0编辑  收藏  举报

导航