javascript - 如果歌剧 - CSS 有什么不同?

标签 javascript css html

如果用户/访问者使用 opera,有什么方法可以覆盖 css 中的某些内容并使用不同的大小?

例如,在 chrome、ff 和 safari 中这很有效:

.section#search h3 a {
    background: url("../img/search.png") no-repeat 0 50%;
    padding: 0 0 0 25px;
    position: relative;
}

但在 Opera 中,填充并不是很好......我需要添加 top: 16px; 到它或将填充更改为 padding: 0 0 36px 25px;

是否有类似 IE 或 javascript 用法的“hack”?没有想法...

我只需要为歌剧添加顶部或新的填充。谢谢 ;)

最佳答案

使用 conditional-css 工具,您可以针对 opera,但引擎很重要。 conditional-css.com 解释说:

Conditional-CSS isn't really all that interested in which browser the user is using, but rather what rendering engine the user's browser utilises. This is why Conditional-CSS uses 'Gecko' rather than the well known Firefox as one of it's browser conditions. Likewise for Safari 'Webkit' is used. This allows other browsers using the same rendering engines to receive the same targeted CSS. An exception to this rule is made for IE (rather than using 'Trident') since this is what the IE conditional comments use and Trident isn't particuarly well known. Similarly for Opera, since only the Opera browser uses it's Presto rendering engine, 'Opera' is used.

http://www.conditional-css.com/advanced

他们写道条件标签的形成方式如下:

[if {!} browser]
[if {!} browser version]
[if {!} condition browser version]

浏览器名称如下:

IE - Internet Explorer
Gecko - Gecko based browsers (Firefox, Camino etc)
Webkit - Webkit based browsers (Safari, Shiira etc)
'SafMob' - Mobile Safari (iPhone / iPod Touch)
Opera - Opera's browser
IEMac - Internet Explorer for the Mac
Konq - Konqueror
IEmob - IE mobile
PSP - Playstation Portable
NetF - Net Front

因此,根据他们的说法,从逻辑上讲,您可以通过以下方式定位: [if Opera]

在 CSS block 中像这样:

[if Opera] .box {  
    width: 500px;  
    padding: 100px 0;  
} 

或者像这样的 CSS 包括:

<!--[if Opera]>

<![endif]-->

关于javascript - 如果歌剧 - CSS 有什么不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10609686/

相关文章:

html - 如何扩展一个 div 元素的宽度而不是整个页面的宽度

html - 如何使用 Golang 检索所选 HTML 元素的高度?

javascript - SharePoint 2013 库检索所有文件名。休息API

javascript - 动画与IE文字阴影冲突

javascript - 用于突出显示文本的 JQuery 选择器

css - 从样式表定位内联 SVG

javascript - 更平滑的 JQuery 宽度变化

javascript - javascript 中 if (a>b) 的有效替代方法,用于检查变量范围

javascript - ReactJS:url更改时不运行useEffect

html - 我怎样才能使用 100% 宽度和固定高度的图像 - 并且让它们不变形?