Break free from CSS prefix hell!

Related tags

CSS prefixfree
Overview

-prefix-free

Break free from CSS prefix hell!

Project homepage

A script that lets you use only unprefixed CSS properties everywhere. It works behind the scenes, adding the current browser’s prefix to any CSS code, only when it’s needed.

API Documentation

Note: To use -prefix-free you don't need to write any JS code, just to include prefixfree.js in your page. The following is meant mostly for plugin authors.

-prefix-free creates 2 global variables: StyleFix and PrefixFree. StyleFix is a framework for building various CSS fixers and -prefix-free depends on it. Currently, StyleFix is bundled with -prefix-free and only available this way, but it might eventually get split to a separate project, with separate documentation.

StyleFix API Documentation

Properties

StyleFix.fixers

An array of the current callbacks.

Functions

StyleFix.register(callback)

Adds callback to the queue of functions that will be called when fixing CSS code. callback will be called with the following parameters:

  • css (String): The CSS code that is being processed,
  • raw (Boolean): Whether the CSS code can contain rules etc or it's just a bunch of declarations (such as the ones found in the style attribute),
  • element (HTMLElement): The node that the CSS code came from (such as a <link> element, a <style> element or any element with a style attribute)

and it should return the fixed CSS code.

StyleFix.link(linkElement)

Processes a <link rel="stylesheet"> element and converts it to a <style> element with fixed code. Relative URLs will be converted.

StyleFix.styleElement(styleElement)

Fixes code inside a <style> element.

StyleFix.styleAttribute(element)

Fixes code inside the style attribute of an element. Will not work in IE and Firefox < 3.6 due to a bug those have with getAttribute('style'): In IE invalid values of valid properties will be dropped, and in Firefox < 3.6 anything invalid will be dropped.

StyleFix.camelCase(str)
StyleFix.deCamelCase(str)

Utility methods that convert a string to camelCase and back.

-prefix-free API Documentation

Properties

PrefixFree.prefix

The detected prefix of the current browser (like '-moz-' or '-webkit-')

PrefixFree.Prefix

The detected prefix of the current browser in camelCase format (like 'Moz' or 'Webkit')

PrefixFree.properties
PrefixFree.functions
PrefixFree.keywords
PrefixFree.selectors
PrefixFree.atrules

Properties/functions/keywords/etc that are only available with a prefix in the current browser.

Functions

PrefixFree.prefixCSS(code [, raw])

Prefixes the properties and values in the code passed with the prefix of the current browser, only when needed. If the second parameter is truthy, it also prefixes selectors and @-rules. This is the most useful method in -prefix-free.

PrefixFree.prefixSelector(selector)
PrefixFree.prefixProperty(property)

Prefixes the passed selector or property. The property is prefixed even when it's supported prefix-less. These are more internal methods and I assume they won't be too useful in general.

Comments
  • box-shadow gets prefixed even when it shouldn't

    box-shadow gets prefixed even when it shouldn't

    IE10 version tested: 10.0.8102.0 When prefixing the box-shadow propertie (like -prefix-free do it on IE10), this propertie doesn't work. Example that doesn't work for IE10: -ms-box-shadow(#6D6D6D 2px 2px 4px) This works for IE10: box-shadow(#6D6D6D 2px 2px 4px)

    You can see this issue on that page: http://jojaba.free.fr/alsacreations/prefixfree-demo/prefixfree-demo.html

    Thanks for your great work

    Fixed 
    opened by Jojaba 24
  • Broken when stylesheet URL contains RegExp chars like +

    Broken when stylesheet URL contains RegExp chars like +

    Behavior RegExp is broken:

    SyntaxError: Invalid regular expression /bla/: Nothing to repeat

    Base URL needs to be escaped before being used in a RegExp.

    Confirmed Fixed 
    opened by gotcha 15
  • -prefix-free disables media query in IE9

    -prefix-free disables media query in IE9

    In IE9 with a linked stylesheet using the media query "only screen and (min-width: 500px)", -prefix-free disables that stylesheet when it loads. Resizing the browser causes the stylesheet to be re-applied.

    Test case: http://eastsussex.gov.uk/testcase/linked.html

    Confirmed 
    opened by sussexrick 15
  •  box-sizing not getting prefixed in FireFox v27

    box-sizing not getting prefixed in FireFox v27

    Hi! I don't know if it's a bug of FF, because, strangely, in your example page box-sizing gets prefixed. Instead, in my page it doesn't get replaced:

    * {
        box-sizing: border-box;
    }
    

    gets me

    * {
    }
    
    opened by aand16 13
  • stopped working on Chrome 26.0.1410.43

    stopped working on Chrome 26.0.1410.43

    I was working on my Mac, with Chrome, and everything was OK. Then I turned on my PC and fired my site, also on Chrome. Immediately I noticed linear-gradients stopped working. After further investigation I realized that the CSS files were being parsed but no property was actually being prefixed.

    Then I checked both browser (on Mac and on PC) versions. Chrome on Mac was outdated (24) and on PC it was up to date (26).

    Simply updated my Chrome on my Mac and the same error (no prefixes) occurred.

    I assume Prefixfree is not working under Chrome 26.

    opened by haggen 12
  • Properties under a

    Properties under a "transition" aren't prefixed

    For example, transition: transform 0.25s ease-in-out; becomes -moz-transition: transform 0.25s ease-in-out;.

    I expected -moz-transition: -moz-transform 0.25s ease-in-out;

    Fixed 
    opened by brian-c 10
  • Add a few new keywords and selectors, fix some of the test suite.

    Add a few new keywords and selectors, fix some of the test suite.

    This adds support for:

    • cursor: grab, cursor: grabbing, width: contains-float
    • ::backdrop, :fullscreen and ::placeholder.

    The tests have improved, but they are still broken...

    opened by pygy 9
  • Relative URLs do not work

    Relative URLs do not work

    Tried out this script today and as soon as I refreshed the page I was working on all of the css background images disappeared as soon as the script loaded. I tried the script first at bottom of page, where I normally put js like this, tried it in the as well.

    I'm on a mac and this bug happened in Chrome 14 and the latest Firefox version 7.0.

    I typically write my css on one line and write background properties like this: background: url(../img/hero-bg.png) no-repeat;

    Would love to use the script but unfortunately won't be able to with this bug.

    Thanks

    Fixed 
    opened by ross999 9
  • Add support for input-placeholder

    Add support for input-placeholder

    Any chance you can add support for styling the input placeholder? AFAIK, following works:

    :-ms-input-placeholder for IE 10+ :-moz-placeholder for Firefox 4+ ::-webkit-input-placeholder for Chrome and Safari

    opened by smares 8
  • IE9: Fallback to XDomainRequest if available.

    IE9: Fallback to XDomainRequest if available.

    On IE9, XMLHttpRequest does not allow to do a crossdomain request. An exception is triggered on open() in this case. We intercept this exception and use XDomainRequest if available.

    This should close #60.

    opened by vincentbernat 8
  • Adding support for grab & grabbing cursors

    Adding support for grab & grabbing cursors

    I needed support for these values in a prototype I'm building and noticed they were omitted. See:

    https://developer.mozilla.org/en/CSS/cursor

    WebKit & Mozilla both implement these values with prefixes.

    opened by timhettler 8
  • Update prefixfree.min.js

    Update prefixfree.min.js

    There have been PRs merged to update prefixfree.js, but the prefixfree.min.js file hasn't been updated for 4 years. Would be good to have this updated to the latest.

    opened by coliff 0
  • grid-column-gap and grid-row-gap support

    grid-column-gap and grid-row-gap support

    Can you add support for "column-gap" and "row-gap"?

    // does not work in iOS Safari 11.1
    column-gap: 10px
    row-gap: 10px
    

    For example iOS Safari 11.1 doesn't understand column-gap and row-gap.

    The prefixed version would be:

    // does work in iOS Safari 11.1
    grid-column-gap: 10px
    grid-row-gap: 10px
    
    opened by LucusWebsites 1
  • disable grid?

    disable grid?

    Thanks for this awesome library!

    I am having IE issues with grid. Is it possible to tell prefix-free not to handle any grid styles?

    Thanks

    By the way, I am including prefixfree.min.js in my project.

    opened by brandoncc 0
  • Caution: StyleFix breaks BrowserSync stream reloading

    Caution: StyleFix breaks BrowserSync stream reloading

    StyleFix converts <link ... /> into <style ... /> , and this breaks BrowserSync automatic style refresh. As a result, BrowserSync stylesheet reloading doesn't work, one needs to fully reload the page. This is probably a wont-fix, but still good to know for some people.

    opened by lastant 2
  • Document.currentScript is null when executed in a module or with eval

    Document.currentScript is null when executed in a module or with eval

    Document.currentScript is null when executed in a module or with eval. This results in an exception on line 14 in prefixfree.js. I understand that the limitations state, "Prefixing code in @import-ed files is not supported." However, I am not sure if that refers to the CSS or the -prefixfree source. Applications run in environments like StackBlitz are bundled or executed with eval where Document.currentScript is always null. This reproduction using -prefixfree and conic-gradients performs a null check.

    var currentScript = document.currentScript;
    var self = window.StyleFix = {
    	optIn: currentScript && currentScript.hasAttribute("data-prefix"),
    

    v1.0.10

    opened by TrevorKarjanis 0
Owner
Lea Verou
Elected @w3ctag member, CSS WG Invited Expert, HCI researcher at MIT CSAIL. Founder of many open source projects, PrismJS probably being the most popular one.
Lea Verou
Spectre.css - A Lightweight, Responsive and Modern CSS Framework

Spectre.css Spectre.css is a lightweight, responsive and modern CSS framework. Lightweight (~10KB gzipped) starting point for your projects Flexbox-ba

Yan Zhu 11.1k Jan 8, 2023
Low-level CSS Toolkit – the original Functional/Utility/Atomic CSS library

Basscss Low-level CSS toolkit – the original Functional CSS library https://basscss.com Lightning-Fast Modular CSS with No Side Effects Basscss is a l

Basscss 5.8k Dec 31, 2022
Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation

Aphrodite Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation. Support for colocating y

Khan Academy 5.3k Jan 1, 2023
CSS Boilerplate / Starter Kit: Collection of best-practice CSS selectors

Natural Selection Natural Selection is a CSS framework without any styling at all. It is just a collection of selectors that can be used to define glo

FrontAid CMS 104 Dec 8, 2022
Source code for Chrome/Edge/Firefox/Opera extension Magic CSS (Live editor for CSS, Less & Sass)

Live editor for CSS, Less & Sass (Magic CSS) Extension Live editor for CSS, Less & Sass (Magic CSS) for Google Chrome, Microsoft Edge, Mozilla Firefox

null 210 Dec 13, 2022
Easily create css variables without the need for a css file!

Tailwind CSS Variables This plugin allows you to configure CSS variables in the tailwind.config.js Similar to the tailwindcss configurations you are u

Mert Aşan 111 Dec 22, 2022
Cooltipz.css - A highly customisable, minimal, pure CSS tooltip library

Cooltipz.css - Cool tooltips Cool customisable tooltips made from pure CSS Lightweight • Accessible • Customisable • Simple Cooltipz.css is a pure CSS

Jack Domleo 110 Dec 24, 2022
micro-library for CSS Flexbox and CSS Grid

SpeedGrid micro-library for CSS Flexbox and CSS Grid Overview SpeedGrid dynamically generates inline CSS by specifying the class name. Easy maintenanc

Toshihide Miyake 7 Mar 26, 2022
Data-tip.css - Wow, such tooltip, with pure css!

Notice: hint.css has been much better since I complained about it months ago, so try out its new features instead of this one! data-tip.css Wow, such

EGOIST 117 May 26, 2021
Tiny CSS framework with almost no classes and some pure CSS effects

no.css INTERACTIVE DEMO I am tired of adding classes to style my HTML. I just want to include a .css file and I expect it to style the HTML for me. no

null 96 Dec 10, 2022
Free responsive one page portfolio template

Portfolio one page template - ARCHIVED Flat and responsive website template, designed and coded by Maxim Orlov. Demo: http://website-templates.github.

Website templates 164 Jan 2, 2023
FREE Bootstrap Landing Page Template for Developers and Startups

Theme Details & Demo Details: https://themes.3rdwavemedia.com/bootstrap-templates/startup/appkit-landing-free-bootstrap-theme-for-developers-and-start

Xiaoying Riley 158 Nov 30, 2022
📱 Free to use static generated website template for your mobile app

Mobile App Landing Page Template ?? Free to use static generated landing page template for your mobile app ?? Features Mobile App Landing Page Templat

Sandoche ADITTANE 467 Dec 30, 2022
Tabler is free and open-source HTML Dashboard UI Kit built on Bootstrap

A premium and open source dashboard template with a responsive and high-quality UI. Preview Tabler is fully responsive and compatible with all modern

Tabler 32.6k Jan 9, 2023
An easy-to-use linux app that lets you create Desktop Shortcuts hassle-free

DeskCut An easy to use app that lets you create Desktop Shortcuts (.desktop files) on Linux without requiring to mess with .desktop files! How to use

null 96 Dec 30, 2022
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.

Bootstrap Sleek, intuitive, and powerful front-end framework for faster and easier web development. Explore Bootstrap docs » Report bug · Request feat

Bootstrap 161k Jan 1, 2023
Modern CSS framework based on Flexbox

Bulma Bulma is a modern CSS framework based on Flexbox. Quick install Bulma is constantly in development! Try it out now: NPM npm install bulma or Yar

Jeremy Thomas 46.6k Dec 31, 2022
A utility-first CSS framework for rapid UI development.

A utility-first CSS framework for rapidly building custom user interfaces. Documentation For full documentation, visit tailwindcss.com. Community For

Tailwind Labs 63.5k Dec 30, 2022
Materialize, a CSS Framework based on Material Design

MaterializeCSS Materialize, a CSS Framework based on material design. -- Browse the docs -- Table of Contents Quickstart Documentation Supported Brows

Alvin Wang 38.8k Jan 2, 2023