我想只使用CSS创建一个关闭按钮。
我相信我不是第一个这样做的人,所以有人知道哪种字体的“x”宽与高相同,这样它就可以跨浏览器使用,看起来像一个关闭按钮吗?
我想只使用CSS创建一个关闭按钮。
我相信我不是第一个这样做的人,所以有人知道哪种字体的“x”宽与高相同,这样它就可以跨浏览器使用,看起来像一个关闭按钮吗?
当前回答
如果使用×-mark(乘法符号),×在HTML中,为了那个?
“x”(字母)不能用来表示字母x以外的任何东西。
其他回答
以防万一,有人正在搜索正确和错误的标记:
char rightMark = '\u2713';
char wrongMark = '\u2717';
将打印:
✓ Right Mark
✗ Wrong Mark
我更喜欢字体很棒:http://fortawesome.github.io/Font-Awesome/icons/
你要找的图标是fa-times。使用起来很简单:
<button><i class="fa fa-times"></i> Close</button>
小提琴在这里
HTML
✕ ✕ ✓ ✓ ✖ ✖ ✔ ✔
✗ ✗ ✘ ✘
× × ×
CSS
在::before或::after伪元素中使用转义的\ Unicode HEX值,如下所示:
[class^="ico-"], [class*=" ico-"] { 字体:normal 1em/1 Arial, sans-serif; 显示:inline-block; } .ico-times::before{内容:"\2716";} .ico-check::before{内容:"\2714";} <i class="ico-times" role="img" aria-label="Cancel"></i> . <i class="ico-check" role="img" aria-label="Accept"></i> .
用例:
Language | Syntax | Example |
---|---|---|
HTML | ✕ | <button class="close" type="button">✕ Close</button> |
CSS | \2715 | .close::before { content: '\2715'; } |
JavaScript | \u2715 | document.querySelector(".close").prepend("\u2715") |
https://home.unicode.org/
报;比✖& # 10006;在Edge和Internet explorer(在IE11中测试)中表现异常。它没有得到正确的颜色,并被一个“表情符号”所取代
还有一个没有在这里提到-很薄-如果你的项目需要这样的外观:╳
╳ or decimal: ╳