CSS 实现关闭按钮 X

<!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>

  

保存html文件,直接可以看到效果。

posted @ 2020-03-20 15:46  Homegu  阅读(820)  评论(0编辑  收藏  举报