Unicode character for “X” cancel / close?

前端 未结 17 1930
我在风中等你
我在风中等你 2021-01-29 17:18

I want to create a close button using CSS only.

I\'m sure I\'m not the first to do this, so does anyone know which font has an \'x\' the same width as height, so that it

相关标签:
17条回答
  • 2021-01-29 17:47

    This is for people who want to make their X small/big and red!

    HTML:

    <div class="col-sm-2"> <span><div class="red-x">&#10006;</div></span>
        <p>close</p>
    </div>
    
    <div class="red-x big-x">&#10006;</div>
    

    CSS:

    .red-x {
    color: red;
    }
    
    .big-x {
    font-size: 70px;
    text-align: center;
    }
    
    0 讨论(0)
  • 2021-01-29 17:49

    You can use text that is only accessible to screen readers by placing it in a span which you hide in an accessible way. Place the x in the CSS which can't be read by screen readers, thus won't confuse, but is visible on the page, and also accessible by keyboard users.

    <style>
    .hidden {opacity:0; position:absolute; width:0;}
    .close {padding:4px 8px; border:1px solid #000; background-color:#fff; cursor:pointer;}
    .close:before {content:'\00d7'; color:red; font-size:2em;}
    </style>
    
    <button class="close"><span class="hidden">close</span></button>
    
    0 讨论(0)
  • 2021-01-29 17:49
    &#x274C;
    

    looks like:

    its good for me :)

    0 讨论(0)
  • 2021-01-29 17:54

    As @Haza pointed out the times symbol can be used. Twitter Bootstrap maps this to a close icon for dismissing content like modals and alerts.

    <button class="close">&times;</button>
    
    0 讨论(0)
  • 2021-01-29 17:57

    &times; is better than &#10006; as &#10006; behaves strangely in Edge and Internet explorer (tested in IE11). It doesn't get the right color and is replaced by an "emoji"

    0 讨论(0)
  • 2021-01-29 17:58

    × &#215; or &times; (same thing) U+00D7 multiplication sign

    × same character with a strong font weight


    &#10799; U+2A2F Gibbs product


    &#10006; U+2716 heavy multiplication sign


    There's also an emoji ❌ if you support it. If you don't you just saw a square = &#10060;


    I also made this simple code example on Codepen when I was working with a designer who asked me to show her what it would look like when I asked if I could replace your close button with a coded version rather than an image.

    <ul>
      <li class="ele">
        <div class="x large"><b></b><b></b><b></b><b></b></div>
        <div class="x spin large"><b></b><b></b><b></b><b></b></div>
        <div class="x spin large slow"><b></b><b></b><b></b><b></b></div>
        <div class="x flop large"><b></b><b></b><b></b><b></b></div>
        <div class="x t large"><b></b><b></b><b></b><b></b></div>
        <div class="x shift large"><b></b><b></b><b></b><b></b></div>
      </li>
      <li class="ele">
        <div class="x medium"><b></b><b></b><b></b><b></b></div>
        <div class="x spin medium"><b></b><b></b><b></b><b></b></div>
        <div class="x spin medium slow"><b></b><b></b><b></b><b></b></div>
        <div class="x flop medium"><b></b><b></b><b></b><b></b></div>
        <div class="x t medium"><b></b><b></b><b></b><b></b></div>
        <div class="x shift medium"><b></b><b></b><b></b><b></b></div>
    
      </li>
      <li class="ele">
        <div class="x small"><b></b><b></b><b></b><b></b></div>
        <div class="x spin small"><b></b><b></b><b></b><b></b></div>
        <div class="x spin small slow"><b></b><b></b><b></b><b></b></div>
        <div class="x flop small"><b></b><b></b><b></b><b></b></div>
        <div class="x t small"><b></b><b></b><b></b><b></b></div>
        <div class="x shift small"><b></b><b></b><b></b><b></b></div>
        <div class="x small grow"><b></b><b></b><b></b><b></b></div>
    
      </li>
      <li class="ele">
        <div class="x switch"><b></b><b></b><b></b><b></b></div>
      </li>
    </ul>
    
    0 讨论(0)
提交回复
热议问题