热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

仅适用于Chrome的CSS?-CSSthatonlyappliestoChrome?

Thisismysite:http:portable-ebook-reader.net这是我的网站:http:portable-ebook-reader.netThesearc

This is my site: http://portable-ebook-reader.net

这是我的网站:http://portable-ebook-reader.net

The search bar at the top is made up of two background images. One is for where you'd type in the search phrase, the second is the actual button to search.

顶部的搜索栏由两个背景图像组成。一个用于输入搜索短语的位置,第二个是要搜索的实际按钮。

My problem is that in Chrome the search button image is 2px too HIGH. But it looks perfect in IE and FF. And if I modify the CSS (margin-top: 2px) then Chrome looks good but IE and FF are messed up.

我的问题是在Chrome中,搜索按钮图像的亮度为2px太高。但它在IE和FF中看起来很完美。如果我修改CSS(margin-top:2px),Chrome看起来不错,但是IE和FF搞砸了。

Any ideas? I've been searching for hours without any luck.

有任何想法吗?我一直在寻找没有运气的好几个小时。

Thanks!

7 个解决方案

#1


2  

Get it looking right for FF first. Then get it looking right for both FF and Chrome. Only after you have it looking right in FF and Chrome, should you start concerning yourself with how it looks in IE. After you achieve this, then start adjusting for IE, if necessary, using * before your style rules, example: *margin-top:2px; adjusts the top margin for IE7 and IE6 exclusively.

首先让它适合FF。然后让它适合FF和Chrome。只有在你在FF和Chrome中看起来正确之后,你才应该开始关注它在IE中的外观。完成此操作后,如果需要,在样式规则之前使用*开始调整IE,例如:* margin-top:2px;仅调整IE7和IE6的上边距。

After looking at your code, it's difficult to say exactly what may be causing the problem without being able to test different solutions on my system. But here are some things you can try to change in your styles.css file (located in your 'chronicle' folder within your 'themes' folder) that may correct the issue:

在查看您的代码之后,如果不能在我的系统上测试不同的解决方案,很难确切地说出可能导致问题的原因。但是这里有一些你可以尝试在styles.css文件中更改的东西(位于'themes'文件夹中的'chronicle'文件夹中)可以解决问题:

  • apply the same height value to both your #s and #searchsubmit rule-sets
  • 将相同的高度值应用于#s和#searchsubmit规则集

  • remove font: 14px "century gothic", Arial, Helvetica, sans-serif; from #searchsubmit
  • 删除字体:14px“世纪哥特式”,Arial,Helvetica,sans-serif;来自#searchsubmit

  • after you do the above, if it still doesn't look right in both FF and Chrome, set the first and second padding values for your #s rule-set to 0 (i.e. change 8px to 0px) and then add a margin-top: declaration to both #s and #searchsubmit and give both the same value, for example margin-top:8px;
  • 执行上述操作后,如果在FF和Chrome中仍然看起来不正确,请将#s规则集的第一个和第二个填充值设置为0(即将8px更改为0px),然后添加margin-top :声明#s和#searchsubmit并给两个相同的值,例如margin-top:8px;

  • if you're still having issues, try copying this line: font: normal 100% "Tahoma", Arial, Helvetica, sans-serif; from your #s rule-set and add it to your #searchsubmit rule-set so that it appears in both rule-sets.
  • 如果你还有问题,请尝试复制这一行:font:normal 100%“Tahoma”,Arial,Helvetica,sans-serif;从您的#s规则集中将其添加到您的#searchsubmit规则集中,以便它出现在两个规则集中。

There's so many different possibilities that could be causing the problem, which is why you may want to try one of the aforementioned hacks if you can't figure out the source of the problem.

有很多不同的可能性可能导致问题,这就是为什么你可能想要尝试上述黑客之一,如果你无法找出问题的根源。

#2


34  

To use CSS that will only apply to Webkit browsers (Chrome and Safari):

要使用仅适用于Webkit浏览器的CSS(Chrome和Safari):

@media screen and (-webkit-min-device-pixel-ratio:0) { 
    #searchsubmit { height: 20px; }
    #s { margin-top: 5px; } 
}

An ugly hack but it can work for those frustrating rendering problems.

一个丑陋的黑客,但它可以解决那些令人沮丧的渲染问题。

#3


3  

You could check to see if navigator.appVersion contains the word "Chrome" and set the relative positioning of that button down a couple pixels via Javascript.

您可以检查navigator.appVersion是否包含单词“Chrome”,并通过Javascript将该按钮的相对位置设置为几个像素。

if (navigator.appVersion.indexOf("Chrome/") != -1) {
 // modify button 
}

#4


1  

Try changing your doctype to strict - whatever works in one should mostly work the same in all three major browsers. Mostly.

尝试将您的doctype更改为严格 - 无论哪种工作都应该在所有三种主要浏览器中大致相同。大多。

#5


1  

Just as a reference, a list of all possible browser specific CSS hacks. Although I discourage the use of those hacks, it may suit a quick fix for your problem.

作为参考,列出所有可能的浏览器特定的CSS黑客。虽然我不鼓励使用这些黑客,但它可能适合您的问题的快速解决方案。

#6


1  

I found this trick a couple of weeks ago and it seems to work identically in all browsers.

几个星期前我发现了这个技巧,它似乎在所有浏览器中都有相同的功能。

Create a single graphic that contains both your search bar and search button. Make it the background of your form through CSS styling. Then adjust both your text input and submit button (likely through classes or IDs) to have {border:0; background:transparent} and then simply adjust the height and width of the form elements to fit the layout of your form background. I formerly used but could never get the alignment quite right no matter how I styled or padded it. This method works right pretty much after your first adjustment of the form elements' margin, padding and absolute positioning if need by (you might want to leave the borders visible during testing just so you can place it properly).

创建一个包含搜索栏和搜索按钮的图形。通过CSS样式使其成为表单的背景。然后调整文本输入和提交按钮(可能通过类或ID)以{border:0; background:transparent}然后简单地调整表单元素的高度和宽度以适合表单背景的布局。我以前使用但无论我如何设计或填充它,都无法使对齐方式完全正确。在您第一次调整表单元素的边距,填充和绝对定位(如果需要)之后,此方法几乎可以正常工作(您可能希望在测试期间保持边框可见,这样您就可以正确放置它)。

I also find it handy to put a {cursor:pointer;} over my search submit button and sometimes even other form inputs to give a visual clue that this is a submittable form and people are encouraged to click.

我还发现将{cursor:pointer;}放在我的搜索提交按钮上,有时甚至是其他表单输入,以便给出一个可视化的线索,这是一个可提交的表单,并鼓励人们点击它。

#7


-1  

Have a look at http://rafael.adm.br/css_browser_selector/

看看http://rafael.adm.br/css_browser_selector/

little js file that adds classes to your body tag like .webkit, .chrome etc which you can thus use in your stylesheet.

little js文件,它将类添加到你的body标签,如.webkit,.chrome等,你可以在样式表中使用它们。


推荐阅读
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • Voicewo在线语音识别转换jQuery插件的特点和示例
    本文介绍了一款名为Voicewo的在线语音识别转换jQuery插件,该插件具有快速、架构、风格、扩展和兼容等特点,适合在互联网应用中使用。同时还提供了一个快速示例供开发人员参考。 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • FeatureRequestIsyourfeaturerequestrelatedtoaproblem?Please ... [详细]
  • Android开发实现的计时器功能示例
    本文分享了Android开发实现的计时器功能示例,包括效果图、布局和按钮的使用。通过使用Chronometer控件,可以实现计时器功能。该示例适用于Android平台,供开发者参考。 ... [详细]
  • 深入理解CSS中的margin属性及其应用场景
    本文主要介绍了CSS中的margin属性及其应用场景,包括垂直外边距合并、padding的使用时机、行内替换元素与费替换元素的区别、margin的基线、盒子的物理大小、显示大小、逻辑大小等知识点。通过深入理解这些概念,读者可以更好地掌握margin的用法和原理。同时,文中提供了一些相关的文档和规范供读者参考。 ... [详细]
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
  • jQuery实现简单的动画效果及用法详解
    本文详细介绍了使用jQuery实现简单动画效果的方法,包括显示/隐藏、向上收缩/向下展开、淡入/淡出、自定义动画等。同时提供了具体的用法示例,并解释了参数的含义和使用技巧。通过本文的学习,读者可以掌握如何使用jQuery实现各种动画效果,为网页增添生动和互动性。 ... [详细]
  • Introduction(简介)Forbeingapowerfulobject-orientedprogramminglanguage,Cisuseda ... [详细]
  • 本文介绍了django中视图函数的使用方法,包括如何接收Web请求并返回Web响应,以及如何处理GET请求和POST请求。同时还介绍了urls.py和views.py文件的配置方式。 ... [详细]
  • FineReport平台数据分析图表显示部分系列接口的应用场景和实现思路
    本文介绍了FineReport平台数据分析图表显示部分系列接口的应用场景和实现思路。当图表系列较多时,用户希望可以自己设置哪些系列显示,哪些系列不显示。通过调用FR.Chart.WebUtils.getChart("chartID").getChartWithIndex(chartIndex).setSeriesVisible()接口,可以获取需要显示的系列图表对象,并在表单中显示这些系列。本文以决策报表为例,详细介绍了实现方法,并给出了示例。 ... [详细]
  • macOS Big Sur全新设计大版本更新,10+个值得关注的新功能
    本文介绍了Apple发布的新一代操作系统macOS Big Sur,该系统采用全新的界面设计,包括图标、应用界面、程序坞和菜单栏等方面的变化。新系统还增加了通知中心、桌面小组件、强化的Safari浏览器以及隐私保护等多项功能。文章指出,macOS Big Sur的设计与iPadOS越来越接近,结合了去年iPadOS对鼠标的完善等功能。 ... [详细]
  • ECMA262规定typeof操作符的返回值和instanceof的使用方法
    本文介绍了ECMA262规定的typeof操作符对不同类型的变量的返回值,以及instanceof操作符的使用方法。同时还提到了在不同浏览器中对正则表达式应用typeof操作符的返回值的差异。 ... [详细]
  • 本文介绍了pack布局管理器在Perl/Tk中的使用方法及注意事项。通过调用pack()方法,可以控制部件在显示窗口中的位置和大小。同时,本文还提到了在使用pack布局管理器时,应注意将部件分组以便在水平和垂直方向上进行堆放。此外,还介绍了使用Frame部件或Toplevel部件来组织部件在窗口内的方法。最后,本文强调了在使用pack布局管理器时,应避免在中间切换到grid布局管理器,以免造成混乱。 ... [详细]
author-avatar
姬跋征
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有