【问题标题】:Browser Hack stopped working in Fluid DesignBrowser Hack 停止在 Fluid Design 中工作
【发布时间】:2012-02-05 08:56:33
【问题描述】:

我有一个浏览器黑客的小问题,我的一个缩略图在 webkit 浏览器中需要比 Firefox 低几个像素,并且它本身就可以正常工作,如下所示:

#thumbsicon
{
position: absolute;
margin: 596px 0px 0px 150px;
opacity:0.6;
filter:alpha(opacity=60); /* For IE8 and earlier */
}

@media screen and (-webkit-min-device-pixel-ratio:0){
#thumbsicon
{
position: absolute;
margin: 525px 0px 0px 150px;
opacity:0.6;
}
}

但是当我使用 @media all 和 (max-height: 640px) 更新 CSS 以进行流畅的响应设计时, 我复制/粘贴 css 并更新相应新尺寸的边距,Webkit 浏览器忽略所有 webkit css hack。

(这是精简版)

@media all and (max-height: 640px) 
{

#thumbsicon
{
position: absolute;
margin: 596px 0px 0px 150px;
opacity:0.6;
filter:alpha(opacity=60); /* For IE8 and earlier */
background: yellow;
}


@media screen and (-webkit-min-device-pixel-ratio:0){
#thumbsicon
{
position: absolute;
margin: 525px 0px 0px 150px;
opacity:0.6;
}
}
}

代码中没有错误,花两天时间寻找和谷歌搜索...使用@media all 时,hack 不起作用

或者我盲目地忽略了一个语义错误?

谢谢,

【问题讨论】:

  • 如果 IE8 从未在移动浏览器上运行,您为什么要在 @media 调用中加入 IE8 破解?我建议保持静态。
  • 它主要是处理不同的屏幕尺寸和浏览器窗口尺寸IE8只是在那里作为在互联网上找不到firefox的人的备份......

标签: css media-queries fluid-layout


【解决方案1】:

第二个@media在第一个。
改为:

@media all and (max-height: 640px) {
    #thumbsicon {
        position: absolute;
        margin: 596px 0px 0px 150px;
        opacity:0.6;
        filter:alpha(opacity=60); /* For IE8 and earlier */
        background: yellow;
    }
}

@media screen and (-webkit-min-device-pixel-ratio:0) {
    #thumbsicon {
        position: absolute;
        margin: 525px 0px 0px 150px;
        opacity:0.6;
    }
}

或到:

@media all and (max-height: 640px) {
    #thumbsicon {
        position: absolute;
        margin: 596px 0px 0px 150px;
        opacity:0.6;
        filter:alpha(opacity=60); /* For IE8 and earlier */
        background: yellow;
    }
}

@media screen and (-webkit-min-device-pixel-ratio:0) and (max-height: 640px) {
    #thumbsicon {
        position: absolute;
        margin: 525px 0px 0px 150px;
        opacity:0.6;
    }
}

另见example

【讨论】:

  • 谢谢,它工作得很好。我实际上有这个作为解决方案,但搞砸了所有的括号。干杯。
  • 不客气。如果您对答案满意,请mark it as the accepted answer
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-11
  • 2012-08-18
  • 2018-08-16
  • 1970-01-01
  • 2023-03-09
相关资源
最近更新 更多