Giter VIP home page Giter VIP logo

universal.css's Introduction

universal.css

The only CSS you will ever need.

Features:

  • Self-documented classnames
  • Zero dependencies
  • Classnames are reusable across projects
  • Removes the need for a CSS preprocessor
  • Removes the need for a CSS bundler
  • No more custom CSS required
  • No need to switch between HTML and CSS file while developing
  • HTTPS ready
  • No more debate about rule naming (dash, double dash or underscore?). The CSS spec is all we need!

Usage

Insert this one line in your HTML source file:

<link rel="stylesheet" src="https://cdn.rawgit.com/marmelab/universal.css/master/universal.css" />

Then you can change the CSS classes in your HTML to universal CSS classes:

Before:

<!-- index.html -->
<div class="sidebar">
    <!-- sidebar content -->
</div>
/* main.css */
.sidebar {
    border-top: 1.04em dotted lightgrey;
    border-bottom: 12px solid cornflowerblue;
    border-top-right-radius: 1.60em;
    padding: 5px;
    margin-left: 10px;
    background-color: fuchsia;
}

After:

<!-- index.html -->
<div class="
  border-top-width-1-dot-04em
  border-top-style-dotted
  border-top-color-lightgrey
  border-bottom-width-12px
  border-bottom-style-solid
  border-bottom-color-cornflowerblue
  border-top-right-radius-1-dot-60em
  padding-5px
  margin-left-10px
  background-color-fuchsia
">
    <!-- sidebar content -->
</div>
/* main.css */
/* Nothing! */

Check out our demo

FAQ

Where is the documentation?

You don't need documentation. Take any CSS rule you want to apply, replace : by -, and dots by -dot-, and you get the name of the corresponding universal css classname. For instance,

border-top-right-radius: 1.60em => .border-top-right-radius-1-dot-60em

How can you know which classes I need?

We use a smart CSS generator, based on statistical analysis of most used CSS rules, and coupled with a sophisticated prediction engine. Check out the source code for details.

Do you provide a minified version?

universal.css is already highly optimized, and wouldn't benefit much from minification. Check this extract of the source code for a glimpse of the universal.css file syntax.

.color-black { color: black; }
.background-color-black { background-color: black; }
.border-color-black { border-color: black; }
.color-blanchedalmond { color: blanchedalmond; }
.background-color-blanchedalmond { background-color: blanchedalmond; }
.border-color-blanchedalmond { border-color: blanchedalmond; }

But universal.css weights several MBs. How can I optimize the rendering time?

You're covered! If you don't want your users to download a large CSS file, replace the <link> tag with a <script> tag:

<script src="https://cdn.rawgit.com/marmelab/universal.css/master/universalCssGenerator.js"></script>

That's right! Our generator works both in the backend and in the frontend - it is truly universal. The JavaScript file is much lighter, and will load very quickly. Once loaded, it generates the universal.css styles directly in the browser.

I need a class for Webdings Fonts.

Universal.css is a community effort, currently at an early stage. We don't yet cover all CSS rules, but we welcome every Pull Request helping us to achieve feature completeness.

How can I deal with responsive designs and break points?

We're studying the question, please open an issue if you have a good idea about how to do it.

Where did you get the inspiration from?

Bootstrap V4 recently introduced spacing utility classes like m-t-1 (which translates to margin-top: 1rem!important), and we thought we'd expand this idea to more classes.

Is this a joke?

Of course it's a joke. Use semantic CSS class names.

License

Universal.css is provided free of charge, courtesy of marmelab, under the WTFPL License.

universal.css's People

Contributors

brikou avatar fzaninotto avatar jpetitcolas avatar kmaschta avatar kyleamathews avatar robinbressan avatar shnoulle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

universal.css's Issues

Full documentation ?

Can we have a full documentation with all the utility classes ? Please it will save me so many time to not look into your sources.

HTTPS support?

Just curious (sorry if this has been asked already), but will you guys support HTTPS over CSS? I need to secure some data while it's being sent over the pipe.

Was looking over the css file but found no workable solution, thanks.

Edit: Also, I need some help setting up a HTTP server within CSS too. But, cannot seem to get it working with nodejs... Node can read my css file, but JS doesn't seem to run well in it, any idea?

Edit2: I also tried the old CDATA style syntax, for example:

//<![CDATA[
...code...
//]]>

within CSS to run with node, but with no luck.

support for {border: none;}

We need to repair the typos on lines 432, 66645, 69828, 73011, and 76194, which are respectively:

Row Is Should be
432 .border-style-lone { border-style: lone; } .border-style-none { border-style: none; }
66645 .border-bottom-style-lone { border-bottom-style: lone; } .border-bottom-style-none { border-bottom-style: none; }
69828 .border-left-style-lone { border-left-style: lone; } .border-left-style-none { border-left-style: none; }
73011 .border-right-style-lone { border-right-style: lone; } .border-right-style-none { border-right-style: none; }
76194 .border-top-style-lone { border-top-style: lone; } .border-top-style-none { border-top-style: none; }

Obscure Package Manger Support

I am using another package manager you will never hear of or use, but I want support for it. Now. And it needs to auto-update via Github.

Thanks.

Took me a second......

....almost opened an issue to rail you guys for this, then I saw the joke statement at the bottom. Good one.

Licence

Can you please include a copy of the licence in the repository. I suggest using the WTFPL v2.

Support matrix3d values

While I really like this idea I can't use it since it does not support transform: martix3d().

Could you add the matrix3d values?

Since matrix3d takes 16 values and each can be any valid 32bit integer this might take some space, but should be worth it in the end.

Not working

I think the site is down, i was able to use this a few hrs ago, but now it does not seem to make a change
Please check.

Conflicts with universal-squared.css

I'm needing to use this CSS alongside my fork universal-squared, but I'm getting inconsistent behavior depending on which stylesheet I include first.

Not sure if using universal.css is going to be an option for me if you can't get this fixed.

Make this generated ( FILE SIZE )

Instead of having the file be CSS to start, why not use javascript to build the stylesheet on the fly instead?

Instead of a css files that has border-width-1px, border-width-2px, ... border-width-npx, change to something like for (x in [1...n]) { outputs.push('border-width-' + x + ' { border-width: ' + x + 'px; }'); }

Right now the css is 5 megs, but it could be much MUCH smaller if js was used to build a stylesheet. The stylesheet would still be 5 megs, but the js downloaded would be only like <50k

Is Tailwind CSS a rip-off of this?

I've recently heard about an immensely popular CSS framework called Tailwind CSS.

And I could not help but notice how suspiciously similar the approach looks to universal.css (my favorite framework that I've been using in every project for the last years).

Now I'm just wondering, what helped Tailwind to become so popular, and if there is some kind of legal action planned...?

Missing class-based media queries

I think this framework is missing the most useful feature of 2018. The class-based media queries! Where them are? I'm totally missing them.

For example

<section class="w-800-@-1200"></section>

or at least a longer version:

<section class="border-bottom-red-at-1200"></section>

Add missing properties :turtle:

This issue can be used as a tracker to make sure that all properties and values are supported. Start of a list below:

  • animation-delay
  • animation-direction
  • animation-duration
  • animation-fill-mode
  • animation-iteration-count
  • animation-name
  • animation-play-state
  • animation-timing-function
  • background-attachment
  • background-blend-mode
  • background-clip
  • background-color
  • background-image
  • background-origin
  • background-position
  • background-repeat
  • background-size
  • border-bottom-color
  • border-bottom-left-radius
  • border-bottom-right-radius
  • border-bottom-style
  • border-bottom-width
  • border-collapse
  • border-image-outset
  • border-image-repeat
  • border-image-slice
  • border-image-source
  • border-image-width
  • border-left-color
  • border-left-style
  • border-left-width
  • border-right-color
  • border-right-style
  • border-right-width
  • border-top-color
  • border-top-left-radius
  • border-top-right-radius
  • border-top-style
  • border-top-width
  • bottom
  • box-shadow
  • box-sizing
  • break-after
  • break-before
  • break-inside
  • caption-side
  • clear
  • clip
  • color
  • content
  • cursor
  • direction
  • display
  • empty-cells
  • float
  • font-family
  • font-kerning
  • font-size
  • font-stretch
  • font-style
  • font-variant
  • font-variant-ligatures
  • font-weight
  • height
  • image-rendering
  • isolation
  • left
  • letter-spacing
  • line-height
  • list-style-image
  • list-style-position
  • list-style-type
  • margin-bottom
  • margin-left
  • margin-right
  • margin-top
  • max-height
  • max-width
  • min-height
  • min-width
  • mix-blend-mode
  • motion-offset
  • motion-path
  • motion-rotation
  • object-fit
  • object-position
  • opacity
  • orphans
  • outline-color
  • outline-offset
  • outline-style
  • outline-width
  • overflow-wrap
  • overflow-x
  • overflow-y
  • padding-bottom
  • padding-left
  • padding-right
  • padding-top
  • pointer-events
  • position
  • resize
  • right
  • speak
  • table-layout
  • tab-size
  • text-align
  • text-align-last
  • text-decoration
  • text-indent
  • text-rendering
  • text-shadow
  • text-overflow
  • text-transform
  • top
  • touch-action
  • transition-delay
  • transition-duration
  • transition-property
  • transition-timing-function
  • unicode-bidi
  • vertical-align
  • visibility
  • white-space
  • widows
  • width
  • will-change
  • word-break
  • word-spacing
  • word-wrap
  • z-index
  • zoom
  • backface-visibility
  • column-count
  • column-gap
  • column-rule-color
  • column-rule-style
  • column-rule-width
  • column-span
  • column-width
  • align-content
  • align-items
  • align-self
  • flex-basis
  • flex-grow
  • flex-shrink
  • flex-direction
  • flex-wrap
  • justify-content
  • order
  • perspective
  • perspective-origin
  • shape-outside
  • shape-image-threshold
  • shape-margin
  • transform
  • transform-origin
  • transform-style
  • buffered-rendering
  • clip-path
  • clip-rule
  • mask
  • filter
  • flood-color
  • flood-opacity
  • lighting-color
  • stop-color
  • stop-opacity
  • color-interpolation
  • color-interpolation-filters
  • color-rendering
  • fill
  • fill-opacity
  • fill-rule
  • marker-end
  • marker-mid
  • marker-start
  • mask-type
  • shape-rendering
  • stroke
  • stroke-dasharray
  • stroke-dashoffset
  • stroke-linecap
  • stroke-linejoin
  • stroke-miterlimit
  • stroke-opacity
  • stroke-width
  • alignment-baseline
  • baseline-shift
  • dominant-baseline
  • text-anchor
  • writing-mode
  • vector-effect
  • paint-order
  • cx
  • cy
  • x
  • y
  • r
  • rx
  • ry

Closing script tag missing in readme

Hello,

I loved the joke.
However, you left a little mistake in this readme part :

<script src="https://cdn.rawgit.com/marmelab/universal.css/master/universalCssGenerator.js" />

The <script> tag needs a closing tag </script>

Have a nice day :)

Add shorthand rules

In the spirit of functional CSS, which is really really great I would appreciate to have some shorter rules, that are easier to remember! My the first two letters of each property to reduce confusion! bgco for background-color, bora for border-radius etc. This will also help to reduce the overall size of my HTML!

๐Ÿ’ก Icons support?

Example:

.universal-๐ŸŽ‰::before {
    display: inline;
    content: '๐ŸŽ‰';
}

<i class="universal-๐ŸŽ‰"></i> would show ยซ๐ŸŽ‰ยป. Isn't that great? And users could restyle that with any images they want (e.g. ยซ๐ŸŽ‰ยป)! Finally, universal portable icons for everyone.

Bonus: no more unobvious names, you won't have to remember those anymore.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.