Skip to content

Instantly share code, notes, and snippets.

View carlos-sanchez's full-sized avatar

Carlos Sánchez carlos-sanchez

View GitHub Profile
.gradient(@start, @end) {
background-color: mix(@start, @end);
*background-color: @end;
background-image: -moz-linear-gradient(top, @start, @end);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@start), to(@end));
background-image: -webkit-linear-gradient(top, @start, @end);
background-image: -o-linear-gradient(top, @start, @end);
background-image: linear-gradient(to bottom, @start, @end);
background-repeat: repeat-x;
@carlos-sanchez
carlos-sanchez / clearfix-2016.css
Last active March 7, 2017 19:56
Clearfix. when an element only contains floated elements, it collapses on itself. To prevent this behavior, you have to “clearfix” it. We used to do it with an extra element, but not anymore. Note: The space content is one way to avoid an Opera bug when the contenteditable attribute is included anywhere else in the document. Otherwise it causes …
/* Margin collapsing is a feature, not a bug, and—as we can see here—it ensures a better distribution of boxes across the vertical axis.
So for this reason, I think it is better to favor display:block instead of display:table in "clearfix" rules.
As in:
*/
.clearfix:after {
content:" ";
display:block;
clear:both;
@carlos-sanchez
carlos-sanchez / more-mixins
Created November 14, 2013 03:52
More Mixins
/*
A CSS preprocessor allows you to use variables, mixins, functions,
operations, nesting, importing and much more. For that concern,
I personally use LESS but there are also Sass or Stylus which might fit your needs.
Anyway, I’m only going to talk about mixins here. Mixins are like variables but for whole classes.
The best point of mixins is that they can behave like functions and have parameters.
Let’s start with something very simple: a mixin to handle all vendor prefixes whenever
@carlos-sanchez
carlos-sanchez / css3-selectors.css
Created November 14, 2013 03:54
CSS3 Selectors.
/* SELECTORES DE ATRIBUTOS */
/*info ampliada en http://www.netmagazine.com/tutorials/discover-power-css3-selectors */
/*
elemento[atributo^="valor"]{...}
selecciona todos los elementos que disponen de ese atributo y cuyo valor comienza exactamente por la cadena de texto indicada.
Ejemplo: Selecciona todos los enlaces que apuntan a una dirección de correo electrónico
*/
input[type="text"] {
/* */
}
input[type="submit"]{
/* */
}
input[type=button]{
/* */
}
@carlos-sanchez
carlos-sanchez / media-queries.css
Created November 14, 2013 03:58
Media Queries
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
@carlos-sanchez
carlos-sanchez / print.css
Created November 14, 2013 03:59
Print. Okay, there are many things to note here. Let’s start with the color stuff. You have probably understood the point of turning everything into black and white: saving money. Do you know how much a color ink cartridge costs? :D The first four lines take care of 75% of the job by turning the font color to black and removing backgrounds and s…
@media print {
* {
background: none !important;
color: black !important;
box-shadow: none !important;
text-shadow: none !important;
/* Images, vectors and such */
filter: Gray(); /* IE4-8: depreciated */
filter: url('desaturate.svg#grayscale'); /* SVG version for IE10, Firefox, Safari 5 and Opera */
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-family: sans-serif; /* 1 */
@carlos-sanchez
carlos-sanchez / text-gradients.css
Created November 14, 2013 04:04
Text Gradients.
/* CSS text gradients */
h2[data-text] {
position: relative;
}
h2[data-text]::after {
content: attr(data-text);
z-index: 10;
color: #e3e3e3;
position: absolute;
top: 0;
@carlos-sanchez
carlos-sanchez / replace-h1-for-logo.css
Created November 14, 2013 04:08
Replace h1 for logo for SEO reasons.
h1 {
text-indent:-9999px;
margin:0 auto;
width:400px;
height:100px;
background:transparent url("images/logo.jpg") no-repeat scroll;
}