css - 如何修复CSS红色通知气泡

标签 css twitter-bootstrap

我有一个 Html Like,它是我使用 twitter bootstrap 创建的。

<div class="row-fluid" style="padding-top:10px;">
    <div class="noti_bubble"><@= friendRequestCollection.size() @></div>
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
          <i class="icon-eye-open icon-white"></i>
          <span class="caret"></span> 
    </a>
    <ul class="dropdown-menu">
        <@ friendRequestCollection.each(function(user) { @>
            <li id="user-list-<@= user.get('username') @>"><a href="#"><@= user.get('firstName') @></a></li>
        <@ }); @>
    </ul>
 </div>

我正在尝试在眼睛图标上创建一个红色通知气泡,但它看起来不太好。

我的通知气泡 CSS。

.noti_Container {
position: relative;
/* This is just to show you where the container ends */
width: 16px;
height: 16px;
cursor: pointer;
  }

  .noti_bubble {
position: absolute;
top: 2px;
right: 10px;
background-color: red;
color: white;
font-weight: bold;
font-size: 14px;
border-radius: 2px;
}

我想要的是用红色气泡隐藏 Bootstrap 创建的小箭头,当气泡中的数字增加时,气泡大小必须增加右侧。目前它在左侧增加,所以如果气泡内的数字是 100,那么整个眼睛图标就会隐藏在气泡中。

enter image description here

最佳答案

将徽章放置在而不是:

.noti_bubble {
    position: absolute;
    top: 2px;

    /* this will anchor your badge from its left-hand edge at the midpoint of your icon */
    left: 8px;

    background-color: red;
    color: white;
    font-weight: bold;
    font-size: 14px;
    border-radius: 2px;
}

关于css - 如何修复CSS红色通知气泡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18446156/

相关文章:

asp.net-mvc - Twitter.Bootstrap.MVC4 Nuget 包中的导航路由 Controller 问题

javascript - Bootstrap 模态中的链接无法按预期工作

javascript - 2个div之间的神秘空间

javascript - 使用 jQuery 禁用无效

html - 对齐多个图像(垂直居中对齐),标题沿基线对齐

javascript - "data-dismiss"Bootstrap modal Bugando 位置 = "absolute"

html - 以绝对位置将 Div 置于中心的更好方法?

html - 使页脚出现在 z-index 控制的 div 下方

html - Bootstrap 网格无法在智能手机上正确显示

javascript - 切换 css 类以显示/ overflow hidden 不会重新显示内容