css - 在固定错误警报旁边放置 x

标签 css twitter-bootstrap

我正在自定义 Bootstrap 警报消息,因此它固定在页面顶部。唯一的问题是我似乎无法让 x 按钮位于消息的右侧。它看起来像这样(x 是顶部的小红色):

这是 HTML:

<%= content_tag(:div, msg, class: "alert alert-info") %>
<button class="close" data-dismiss="alert">×</button>

这是CSS:

.alert-info {
   position: fixed;
   display: block;
   top: 10px;
 }

.close {
   position: fixed;
   top: 0;
}

如何让 x 与警报垂直居中并在右侧?

最佳答案

http://jsfiddle.net/DLY6Y/19/

对于这种类型的警报消息,我会使用浅红色的。对于固定定位,我会添加额外的自定义类 alert-fixed。

<div class="alert alert-danger alert-dismissable alert-fixed">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><strong>Warning!</strong> Invalid email or password.</div>

关于css - 在固定错误警报旁边放置 x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23318626/

相关文章:

css - 使用 SASS 时无法设置自定义字体 - Ionic 框架

javascript - 如何在 html 网页上添加动画滚动选项?

html - 使面板高度与父 div 匹配

javascript - Bootstrap header Logo 图像未在 Mozilla 中显示

twitter-bootstrap - Bootstrap 3 中 @font-size-h1 的设置在哪里?

html - <div> 背景被剪掉了

html - CSS - 使用已设置最小宽度的文本输入填充包含元素的 float 的剩余空间

css - Bootstrap 如何避免最小宽度的分栏

asp.net - CSS 友好控制适配器导致安全错误?

css - 在 bootstrap 3 的小屏幕上更改类样式?