Table of Contents
一)还在用 background-position-x
二)咦,为嘛还没开始输入文本框就验证变红了?
三)我擦,明明写了 outline: 0可是然并卵啊
最后,还有些其他的
Home Web Front-end HTML Tutorial 【踩坑】近来在Firefox上遇到的一些坑_html/css_WEB-ITnose

【踩坑】近来在Firefox上遇到的一些坑_html/css_WEB-ITnose

Jun 24, 2016 am 11:24 AM

因为工作一年多以来,做的工作基本都是和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 位置
[强制] 必须同时给出水平和垂直方向的位置。

/* good */body { background-position: center top; /* 50% 0% */}/* bad */body { background-position: top; /* 50% 0% */}
Copy after login

一直以来恪守这个规则,但并没有深究原因。

直到这次,真正遇到了问题。才在控制台上发现,原来background-position-x在Firefox下面是**无效**的!!!

二)咦,为嘛还没开始输入文本框就验证变红了?

第二个问题。

项目有个修改密码的表单。验证不通过的话,输入框会加上红色的边框。

然后QA妹纸在描述中说的是:

firefox浏览器中,修改密码页面,输入框中不输入任何字符,输入框颜色也是红的

我还以为又是哪里的js写得不对呢。找了半天,还是决定从样式入手。

Firefox的调试工具面板里,似乎只列出了样式表中的样式。浏览器默认样式的值,很难找到。我只能一点点试验。

最后发现,input输入框好像都带了个required属性。这是HTML5里表示表单元素必填的属性。莫非问题出在这里?试着删除了这个属性,果然解决了。

其实,这红色的边框,并不是border,而是box-shadow啊。

最后得到解决方案是加上这段CSS:

input:required:invalid { box-shadow: none;}
Copy after login

三)我擦,明明写了 outline: 0可是然并卵啊

QA妹纸还反映,登录、注册等视图的各种按钮,在Firefox怎么点击之后,会出现黑色的边框啊?

啥?难道写代码的前端哥们儿不知道在:active、:focus等状态下写个outline:0啊?这不科学。

于是又开始了神奇的探(gu)索(ge)之旅。

这次得到的答案是,这黑色的细线还真不是outline。这是一个奇怪的伪类,::-moz-focus-inner。简直哭死在键盘上。

于是,下面这段代码解决问题:

button::-moz-focus-inner,input[type="reset"]::-moz-focus-inner,input[type="button"]::-moz-focus-inner,input[type="submit"]::-moz-focus-inner,input[type="file"] > input[type="button"]::-moz-focus-inner { border-color: transparent;}
Copy after login

最后,还有些其他的

  • 还有什么clipboardData截图粘贴的问题,见上一篇专栏【在网页中获取截图数据】Chrome和Firefox下的实战经验;

  • 还有些东西,当时写到注释中了,忘了。。

  • TO BE CONTINUED…

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

    HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

    The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

    HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

    Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

    WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

    Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

    GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

    What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

    AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

    How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? Apr 05, 2025 am 06:15 AM

    To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

    HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

    HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

    How to implement adaptive layout of Y-axis position in web annotation? How to implement adaptive layout of Y-axis position in web annotation? Apr 04, 2025 pm 11:30 PM

    The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

    See all articles