【问题标题】:IE9 element with text + floated right element带有文本的 IE9 元素 + 浮动右元素
【发布时间】:2013-02-28 20:01:24
【问题描述】:

我对旁边有一个右浮动图标的链接元素有疑问。在 FF/Chrome 中一切看起来都不错,但在 IE9 中,文本位于容器底部,而不是垂直对齐。

<a href="#" role="button" data-toggle="modal" class="login">
   Login <span class="icon-login"></span>
</a>

.login {
   line-height: 40px;
   height: 40px;
   margin-top: 0;
   position: absolute;
   top: 0;
   right: 0;
   float: right;
}

.icon-login {
   display: inline-block;
   line-height: 40px;
   height: 40px;
   width: 40px;
   float: right;
   padding: 0;
   margin: 0 0 0 20px;
}

它应该是什么样子(绿色是图标的开头)

IE9

有什么想法吗?

【问题讨论】:

    标签: html css internet-explorer internet-explorer-9


    【解决方案1】:

    看起来像 float 问题。

    尝试将 Login 文本包裹在 divfloat 中,将其包裹到 left

    【讨论】:

    • 是的,我希望避免添加额外的标记,但似乎这是唯一的解决方案。谢谢!
    【解决方案2】:

    我认为你可以使用如下所示的东西。

    <a href="#" role="button" data-toggle="modal" class="login">
       Login 
    </a>
    
    .login {
       line-height: 40px;
       height: 40px;
       margin-top: 0;
       position: absolute;
       top: 0;
       right: 0;
       float: right;
       background: url(icon-login.png) right center;
       padding-right:40px;
    }
    

    【讨论】:

    • 是的,这可行,但我更喜欢对我们在整个站点中使用的图标使用相同的标记。不过谢谢!
    猜你喜欢
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 2011-11-06
    • 2014-09-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多