因为工作一年多以来,做的工作基本都是和webkit
系列打交道。
先是做m站,后来做了两个app
内嵌的hybrid
项目,从来只考虑webkit
前缀和相关的伪类。
最近四个多月开始做内部的管理系统,写写样式,偶尔做个calendar
、tree
之类的组件,所有的基本只考虑新版Chrome
。从来没考虑别的问题。
最近在帮人解决firefox
下的一些兼容问题。QA
妹纸提交了一堆“bug”
。Bug
列表让人看了头疼,还有点心虚。囧。
按部就班,先打开控制台。一番研究,发现不少“bug”
都是样式的问题,并不是脚本兼容做得不好。
下面就细数下最近发现的一些bug
,算是做个备忘。以后还是得注意啊。
一)还在用 background-position-x 吗
以前看一些CSS规范,反复强调不要使用background-position-x
之类的属性。
如百度FEX
就指出:
4.6 2D 位置
[强制] 必须同时给出水平和垂直方向的位置。<span class="hljs-comment" style="color: #999988; font-style: italic;">/* good */</span> <span class="hljs-tag" style="color: #000080; font-weight: normal;">body</span> <span class="hljs-rules">{ <span class="hljs-rule"><span class="hljs-attribute" style="color: #008080;">background-position</span>:<span class="hljs-value"> center top</span></span>; <span class="hljs-comment" style="color: #999988; font-style: italic;">/* 50% 0% */</span> <span class="hljs-rule">}</span></span> <span class="hljs-comment" style="color: #999988; font-style: italic;">/* bad */</span> <span class="hljs-tag" style="color: #000080; font-weight: normal;">body</span> <span class="hljs-rules">{ <span class="hljs-rule"><span class="hljs-attribute" style="color: #008080;">background-position</span>:<span class="hljs-value"> top</span></span>; <span class="hljs-comment" style="color: #999988; font-style: italic;">/* 50% 0% */</span> <span class="hljs-rule">}</span></span>一直以来恪守这个规则,但并没有深究原因。
直到这次,真正遇到了问题。才在控制台上发现,原来background-position-x
在Firefox
下面是**无效**
的!!!
二)咦,为嘛还没开始输入文本框就验证变红了?
第二个问题。
项目有个修改密码的表单。验证不通过的话,输入框会加上红色的边框。
然后QA
妹纸在描述中说的是:
firefox
浏览器中,修改密码页面,输入框中不输入任何字符,输入框颜色也是红的
我还以为又是哪里的js写得不对呢。找了半天,还是决定从样式入手。
Firefox
的调试工具面板里,似乎只列出了样式表中的样式。浏览器默认样式的值,很难找到。我只能一点点试验。
最后发现,input
输入框好像都带了个required
属性。这是HTML5
里表示表单元素必填的属性。莫非问题出在这里?试着删除了这个属性,果然解决了。
其实,这红色的边框,并不是border
,而是box-shadow
啊。
最后得到解决方案是加上这段CSS
:
<span class="hljs-tag" style="color: #000080; font-weight: normal;">input</span><span class="hljs-pseudo">:required</span><span class="hljs-pseudo">:invalid</span> <span class="hljs-rules">{ <span class="hljs-rule"><span class="hljs-attribute" style="color: #008080;">box-shadow</span>:<span class="hljs-value"> none</span></span>; <span class="hljs-rule">}</span></span>
三)我擦,明明写了 outline: 0
可是然并卵啊
QA
妹纸还反映,登录、注册等视图的各种按钮,在Firefox
怎么点击之后,会出现黑色的边框啊?
啥?难道写代码的前端哥们儿不知道在:active
、:focus
等状态下写个outline:0
啊?这不科学。
于是又开始了神奇的探(gu)索(ge)之旅。
这次得到的答案是,这黑色的细线还真不是outline
。这是一个奇怪的伪类,::-moz-focus-inner
。简直哭死在键盘上。
于是,下面这段代码解决问题:
<span class="hljs-tag" style="color: #000080; font-weight: normal;">button</span><span class="hljs-pseudo">::-moz-focus-inner</span>, <span class="hljs-tag" style="color: #000080; font-weight: normal;">input</span><span class="hljs-attr_selector">[type="reset"]</span><span class="hljs-pseudo">::-moz-focus-inner</span>, <span class="hljs-tag" style="color: #000080; font-weight: normal;">input</span><span class="hljs-attr_selector">[type="button"]</span><span class="hljs-pseudo">::-moz-focus-inner</span>, <span class="hljs-tag" style="color: #000080; font-weight: normal;">input</span><span class="hljs-attr_selector">[type="submit"]</span><span class="hljs-pseudo">::-moz-focus-inner</span>, <span class="hljs-tag" style="color: #000080; font-weight: normal;">input</span><span class="hljs-attr_selector">[type="file"]</span> > <span class="hljs-tag" style="color: #000080; font-weight: normal;">input</span><span class="hljs-attr_selector">[type="button"]</span><span class="hljs-pseudo">::-moz-focus-inner</span> <span class="hljs-rules">{ <span class="hljs-rule"><span class="hljs-attribute" style="color: #008080;">border-color</span>:<span class="hljs-value"> transparent</span></span>; <span class="hljs-rule">}</span></span>
最后,还有些其他的
-
还有什么
clipboardData
截图粘贴的问题,见上一篇专栏【在网页中获取截图数据】Chrome和Firefox下的实战经验; -
还有些东西,当时写到注释中了,忘了。。
TO BE CONTINUED…

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
