我想只使用CSS创建一个关闭按钮。

我相信我不是第一个这样做的人,所以有人知道哪种字体的“x”宽与高相同,这样它就可以跨浏览器使用,看起来像一个关闭按钮吗?


当前回答

正如@Haza指出的,可以使用时间符号。Twitter Bootstrap将此映射为一个关闭图标,用于解散情态动词和提醒等内容。

<button class="close">&times;</button>

其他回答

控制自己真的很有效。HTML代码是&#10006;

另一种选择是&#x2715:

这是为那些想让他们的X小/大和红色的人准备的!

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;
}

使用现代浏览器,你可以旋转一个+号:

.popupClose:before {
    content:'+';
}
.popupClose {
    position:relative;
    float:right;
    right:10px;
    top:0px;
    padding:2px;
    cursor:pointer;
    margin:2px;
    color:grey;
    font-size:32pt;
    transform:rotate(45deg);
}

然后简单地把下面的HTML放在你需要的地方:

 <span class='popupClose'></span>

是另一个不太厚的好选项。HTML代码是&#10005;,或者十六进制的2715。

报;比&#10006;& # 10006;在Edge和Internet explorer(在IE11中测试)中表现异常。它没有得到正确的颜色,并被一个“表情符号”所取代