jquery - float 和 jQuery UI 按钮

标签 jquery css jquery-ui internet-explorer-7 jquery-ui-button

我在一个元素中使用了 jQuery UI 按钮,它们运行良好。

但是,在 IE7 中,图标不会像它应该的那样 float 。我意识到 IE 尚不支持圆 Angular ,但没关系。

好的浏览器一些浏览器可以正常显示

good example

IE 糟透了 版本 7 没有:

bad example

我从 HTML 中的一个按钮开始

<button type="submit"><span class="ui-icon ui-icon-mail-closed"></span>Send</button>

然后我遍历按钮,在每个按钮上使用一点点 jQuery

$('#content button').each(function() {                
    var icon = $(this).find('span.ui-icon');
    var primaryIcon = icon.attr('class').replace(/ui-icon\s?/, '');
    icon.remove();
    $(this).button({ icons: {primary: primaryIcon }, label: $(this).text() });
});

我只是在它们上调用 button(),但我决定这样做是为了确保我按照设计的方式使用库。

我在图标上也有一些 CSS

button span.ui-icon {
    display: inline;
    float: left;
    margin-right: 0.1em;
}

上面的页面是also available . (我希望缩短为 void HTTP referrer)。

我做错了什么?

非常感谢!

更新

根据 Meder's answer,我尝试将图标制作为内联 block 元素.

button span.ui-icon {
    display: inline;
    float: left;
    margin-right: 0.1em;
    margin-top: -1px;
    /* get rid of margin for inline element */
    #margin: auto; 
    /* this should revert the element to inline as per declaration above */
    #float: none; 
    /* hasLayout = true */ 
    #zoom: 1;
}

然而,这具有使按钮元素消隐的不寻常效果!

IE7 with display: inline-block on icon

我该怎么办?

最佳答案

无论如何,当您 float 一个元素时,它会变成一个 block 状框。显示:内联没用。 并且您应该始终为 float 项设置宽度。

关于jquery - float 和 jQuery UI 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3853171/

相关文章:

javascript - 在文档上触发 div mousemove

javascript - 检测键盘箭头键按下了多长时间?

jquery - 禁用和启用 Jquery 自动完成

jquery - 在jquery UI对话框中,是否可以将一个模式对话框放在另一个模式对话框之上

jquery - 使用 jQuery 进行独立于浏览器的键码处理

javascript - 如何使用 JSON 数据创建 html 表格?

javascript - Bootstrap 模态样式表单验证

html - 如何将有序列表项表与数字对齐?

javascript - 我如何处理 jQuery 中 anchor 文本值更改为 ""的情况?

javascript - 在 jQuery 中添加带有单引号的 HTML 代码