Created
August 25, 2016 21:30
-
-
Save dfrankland/f6fed3e3ccc42e3de482b324126f9542 to your computer and use it in GitHub Desktop.
CSS Checkered pattern that can be used on all modern browsers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-image: | |
linear-gradient(45deg, #ccc 25%, transparent 25%), | |
linear-gradient(135deg, #ccc 25%, transparent 25%), | |
linear-gradient(45deg, transparent 75%, #ccc 75%), | |
linear-gradient(135deg, transparent 75%, #ccc 75%); | |
background-size:25px 25px; /* Must be a square */ | |
background-position:0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px; /* Must be half of one side of the square */ | |
} |
this approach is still really good and helps when IE11 compatibility is necessary!
@GarthDB changing the background size to an even number appears to fix the "faint white line" display issue.
I was using even numbers (20px 20px for size) but still saw the white diagonal line, what I did was change the first two to go from 26% instead of 25% i.e.
background-image:
linear-gradient(45deg, #ccc 26%, transparent 26%),
linear-gradient(135deg, #ccc 26%, transparent 26%),
linear-gradient(45deg, transparent 75%, #ccc 75%),
linear-gradient(135deg, transparent 75%, #ccc 75%);
background-size: 20px 20px; /* Must be a square */
background-position: 0 0, 10px 0, 10px -10px, 0px 10px; /* Must be half of one side of the square */

This works for even as well as odd numbers at any size.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, the
repeating-conic-gradient
gives ugly edges on some zoom levels, and doesn't work on iOS Safari 14.