CSS to achieve close button 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>

  

Save the html file, you can directly see the effect.

Guess you like

Origin www.cnblogs.com/codedisco/p/12532172.html