【问题标题】:content with absolute position not showing in all browsers绝对位置的内容未在所有浏览器中显示
【发布时间】:2014-02-06 14:43:49
【问题描述】:

我正在使用 wordpress+gantry 框架构建一个站点,并选择了响应式布局,并且我在屏幕左侧有一张背景上方的图片。这张左图(某种没有其他内容的垂直侧边栏)与下一个代码绝对定位:

div.imgleft{
content: url('http://coszminart.ro/wp-content/uploads/2014/02/laterala.png');  
position: absolute;
margin-left: 0px; 
margin-top: -1px; 
max-height: 1020px;
height: 100%;
max-width: 570px; 
background-size: cover;
z-index: 1000  !important;
}

我在模板 index.php 中插入标题上方的 div.imgleft 问题:左侧图像未显示在 iexplore 10、11、最新的 mozilla 中,仅在 chrome 和 android 手机中显示。如果我使用 chrome/firefox 检查工具进行验证,则 css 代码加载正常。我读过绝对定位是跨浏览器兼容的,为什么不工作,我的代码有问题吗? ![在此处输入图片说明][1]

感谢您的帮助,抱歉英语不好。

【问题讨论】:

    标签: css cross-browser absolute


    【解决方案1】:

    content 属性与 :before 和 :after 伪元素一起使用,插入生成的内容。

    所以用

     background-image : url('http://coszminart.ro/wp-content/uploads/2014/02/laterala.png'); 
    

    代替内容

    这是工作小提琴http://jsfiddle.net/krunalp1993/Az5GG/1/

    【讨论】:

    • 你好。如果我使用背景图像,图像不会显示在任何浏览器中。它只适用于内容。我发现需要 :before, :after,但是在引入它们之后,左侧图像不会对窗口大小做出反应,它只是处于最大高度。请输入coszminart.ro了解。谢谢。
    • 谢谢,小提琴加载太慢了,我认为它不起作用。问题解决了:)
    • AlwayZ 欢迎老兄:)
    猜你喜欢
    • 2020-11-10
    • 2016-01-25
    • 2012-10-15
    • 2011-06-29
    • 2022-08-17
    • 2012-07-31
    • 2011-02-19
    • 1970-01-01
    • 2015-09-15
    相关资源
    最近更新 更多