允许的警报

要提供警报关闭功能,我们只需要将 data-dismiss="alert" 添加到关闭按钮。

<div class="alert alert-info alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
    </button>
    Sphinx of black quartz, judge my vow
</div>

StackOverflow 文档

.alert-dismissible.close 类是可选的,仅对样式有用。