css - 谷歌浏览器清除 :after-element left, 所有其他浏览器不

标签 css google-chrome

以下代码将在 :before:after 伪选择器中呈现一个带有背景图像的按钮(链接),以获得灵活的交叉浏览结果。问题是,只有 chrome 不明白(safari,我不知道)。

HTML:

<div class="btn-container align-right more-info-btn">
        <a class="btn" href="#">Super Button<i class="arrow-after-right"></i>
    </a>
</div>

CSS:

.btn-container .btn {
    display: inline-block;
    text-decoration: none;
    height: 24px;
    background: transparent url('http://img842.imageshack.us/img842/5052/kdti.png');
    padding: 0 6px;
    font-size: 11px;
    line-height: 21px;
    font-weight: bold;
    color: red;
    font-family: Helvetica, Arial, FreeSans, Verdana, Tahoma, 'Lucida Sans', 'Lucida Sans Unicode', 'Luxi Sans', sans-serif;
}
.btn-container .btn:before {
    content:'';
    display: inline-block;
    background: transparent url('http://img600.imageshack.us/img600/3825/6ppo.png') no-repeat;
    width: 4px;
    height: 100%;
    margin-left: -10px;
    float: left;
}
.btn-container .btn:after {
    content:'';
    display: inline-block;
    background: transparent url('http://img834.imageshack.us/img834/4803/b5zs.png') no-repeat;
    width: 4px;
    height: 100%;
    margin-right: -10px;
    float: right;
}

谷歌浏览器中的按钮: Button in Google Chrome

所有其他浏览器中的按钮: Button in all other browsers

jsFiddle:

http://jsfiddle.net/K7y4U/4/

我已经尝试过不同的 float/clear 组合,但到目前为止都没有成功。

最佳答案

为 .btn_container 设置一个明确的宽度。那会解决你的问题。这是 fiddle http://jsfiddle.net/K7y4U/6/

我做了:.btn-container .btn { width: 90px; }

关于css - 谷歌浏览器清除 :after-element left, 所有其他浏览器不,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17788178/

相关文章:

google-chrome - Chrome 58 不安全 URL 中的数据

javascript - Chrome 中的单个应用程序

css - 为什么这个 textarea 不能在 Chrome 中假设其父级的全高?

html - 文章标签的动态高度

css - yslow 在多个背景上失败?

javascript - 打开标签,等待它完成加载然后关闭它

reactjs - 为什么 chrome 开发工具控制台会在一个网站上显示 Post 500 错误的链接,而在另一个网站上却没有?

HTML、CSS 将 DIV 中的文本与平行 div 中的文本对齐

php - 如何更改主 div 中打印的 div 的顺序?

CSS 不适用于 Firefox