CSS building blocks
2.1K views | +0 today
Follow
CSS building blocks
stuff I use every day
Curated by Lisa Risager
Your new post is loading...
Your new post is loading...
Scooped by Lisa Risager
Scoop.it!

Make dropdown menu push content down in Safari

If a nav menu has a fixed height, the dropdown menu will push content down in Chrome, Firefox and IE, but not in Safari.

 

Change the height to a min-height/height rule:
 

.main-navigation {
    min-height: 4em;
    height: auto;
}

 

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Placeholder color

Firefox apparently applies opacity:0.54 to the placeholder text: http://css-tricks.com/snippets/css/style-placeholder-text/

This will fix:

.input::-moz-placeholder { color:blue; opacity:1;}/* FF 19+ */.input:-moz-placeholder { color:#bbb; opacity:1;}/* FF 18- */
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Justify a horizontal list | Stack Overflow

Use a pseudo element on the ul element:

ul {

margin:0; 

padding:0;

list-style-type: none;

text-align: justify;

}

 

ul:after {

content:"";

width:100%;

display:inline-block;

}

 

li {

display:inline;

}

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Cross-Browser Image Grayscale with CSS | Karl Horky

Cross-Browser Image Grayscale with CSS | Karl Horky | CSS building blocks | Scoop.it
img.grayscale {filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */filter: gray; /* IE6-9 */-webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */}
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Responsive elements that retain their aspect ratio

Responsive elements that retain their aspect ratio | CSS building blocks | Scoop.it

when we specify a padding-bottom value for the same element, the padding measurement is calculated relative to the element’s width:

.rect { width: 100%; height: 0; padding-bottom: 50%; }
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

z-index | CSS-Tricks

z-index | CSS-Tricks | CSS building blocks | Scoop.it

Also note that nesting plays a big role. If an element B sits on top of element A, a child element of element A can never be higher than element B.

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Mediaqueries

@media only screen and (max-device-width: 480px) {

/* hide header and footer on small screen devices */

#header, #footer {

display: none

}

}


@media only screen and (max-width:800px) {

/* linearize navigation under 800px */

nav, nav li, nav a {

float: none;

width: 100%

}

}

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

IE & mobile media queries | Adactio

Solving that pesky Windows Phone 7 problem.
Lisa Risager's insight:
<link rel="stylesheet" href="/css/global.css" media="all"> <link rel="stylesheet" href="/css/layout.css" media="all and (min-width: 30em)"> <!--[if (lt IE 9)&(!IEMobile)]> <link rel="stylesheet" href="/css/layout.css" media="all"> <![endif]-->
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

get rid of a 2px space between image and parent div | Stack Overflow

Lisa Risager's insight:

This issue is caused by the line-height, because text is expected, too.

line-height:0; 

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Cross browser alpha transparent background CSS (rgba) | Fetched from hammerspace

#div { background:rgb(255,0,0); background: transparent\9; background:rgba(255,0,0,0.3); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4cFF0000,endColorstr=#4cFF0000); zoom:1;}
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Pure CSS folded-corner effect | Nicolas Gallagher

Pure CSS folded-corner effect | Nicolas Gallagher | CSS building blocks | Scoop.it
The folded-corner is created from a pseudo-element that is positioned in the top corner of the box. The pseudo-element has no width or height but is given a thick border. Varying the size of the border will vary the size of the folded-corner.

In this example, the top and right borders are set to colours that match the background colour of the box’s parent. The left and bottom border are then given a slightly darker or lighter shade of the box’s background colour.

.note:before { content:""; position:absolute; top:0; right:0; border-width:0 16px 16px 0; border-style:solid; border-color:#658E15 #fff; }
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

CSS Background Property | Vanseo Design

CSS Background Shortcut

While you can specify each background property (PDF) individually, in practice you’ll want to use the shortcut. When using the shortcut you should specify properties in the following order: color, image, repeat, attachment, position.

1 div {background: #0088ff, url("path-to-an-image"), repeat-x, scroll, top left}

You don’t need to specify all the properties when using the shortcut, but you do want to use the right order. Any property you don’t specify will be assigned a default value as follows:

background-color: transparentbackground-image: nonebackground-repeat: repeatbackground-attachment: scrollbackground-position: 0% 0%
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Facebook Like Box flyout | Stickleblog

Facebook changed the Like Box from a popup to a flyout creating havoc on responsive sites with:embed, iframe, object { max-width: 100%; } Fixed with:.fb-like iframe { max-width: none; }
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Style Placeholder Text | CSS-Tricks

::-webkit-input-placeholder {color: red;}

:-moz-placeholder {/* Firefox 18- */color: red;}

::-moz-placeholder {/* Firefox 19+ */color: red;}

:-ms-input-placeholder {color: red;}

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Test a website for Retina on Windows without an actual Retina display? | Stack Overflow

using Firefox:

Go to "about:config"Find "layout.css.devPixelsPerPxChange it to your desired ratio (1 for normal, 2 for retina, etc.)

Refresh your page - boom, your media query has now kicked in! Hats off to Firefox for being awesome for web developing!

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Three Line Menu Navicon | CSS-Tricks

Three Line Menu Navicon | CSS-Tricks | CSS building blocks | Scoop.it
Pseudo box-shadow

Nothing but semantic markup:

<a href="#menu" class="box-shadow-menu"> Menu </a>

In CSS, make some space on the left of the link with some padding-left. Set the positioning context with relative positioning. Then make a single black line absolutely positioned into that space on the top left. Then using box-shadow, make two more lines beneath it.

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Height equals width with pure CSS | Made My Day

Height equals width with pure CSS | Made My Day | CSS building blocks | Scoop.it
.box{ position: relative; width: 50%; /* desired width */ }
.box:before{ content: ""; display: block; padding-top: 100%; /* initial ratio of 1:1*/ }
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

What No One Told You About Z-Index | Philip Walton

The solution is to add an opacity value less than 1 to the first <div> (the parent of the red<span>). Here is the CSS that was added to the Codepen above:

div:first-child { opacity: .99; }

If you're scratching your head right now in shock and disbelief that opacity would have any effect on which elements are stacked in front of which, welcome to the club. I was similarly shocked when I first stumbled upon this issue.

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

CSS calc

The CSS calc value allows developers to calculate margin, width, height, and other measurement values.

 

The calc routine is especially useful when calculating relative widths. Calculations can be additions, subtractions, multiplications, and divisions.

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Styling telephone numbers | Webdesigntuts+

Styling telephone numbers | Webdesigntuts+ | CSS building blocks | Scoop.it
a[href^="tel:"]:before {    content: "\260E";    display: block;    margin-right: 0.5em;
}
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Equal Height Columns with Cross-Browser CSS and No Hacks

Equal Height Columns with Cross-Browser CSS and No Hacks | CSS building blocks | Scoop.it
A step by step tutorial explaining how to create multicolumn layouts with divs and CSS where every column is the same height

 

A floated container div will always be the height of it's floated contents

This is the central principle behind this equal column height method. The only way to make the height of a div equal to the tallest column is if that div contains all the columns. So to explain this another way, by placing the columns inside a container we cause the container to be the height of the tallest column.

more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

Solving IE7 & IE8 PNG Opacity Problems

Solving IE7 & IE8 PNG Opacity Problems | CSS building blocks | Scoop.it

This is a great little hack.The caveat is that it does not work for IE6, and the PNG may need to be tweaked a bit for it to display correctly.

#demo { background:url(ie8-logo.png) 0 0 no-repeat; filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=#00FFFFFF, endColorstr=#00FFFFFF ); }
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

CSS3: spread value and box-shadow on one side only | Fleeting Epiphanies

Create a shadow on one side only.

 

div { -webkit-box-shadow: 0 8px 6px -6px black; -moz-box-shadow: 0 8px 6px -6px black; box-shadow: 0 8px 6px -6px black; }
more...
No comment yet.
Scooped by Lisa Risager
Scoop.it!

WP Gallery Disable CSS | The Code Collective

Add to functions.php to remove the CSS that wordpress adds when you add a gallery in a post/page:

 

add_filter('gallery_style', create_function('$a', 'return "";'));

more...
No comment yet.