AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Rainbow zebra stripes12/8/2023 IPhone 5, iPhone 5s, iPhone 5c, iPhone SE: 640x1136 IPhone: iPhone 2G, iPhone 3G, iPhone 3GS: 320x480 See the Pen Repeating gradients by Christopher Cohen ( on CodePen.MacBook Pro 13.3" Retina, MacBook Air 13" Retina, MacBook Air 13.3"(2020, M1): 2560x1600 Dual monitor: This is useful when styling progress bars, etc., with overlapping gradient-filled boxes. I don’t know if Chrome just calculates to a different precision for % vs px, but I found this got me beautifully neat lines.Īnother quick tip sometimes you need to specify background-attachment: fixed or it ignores background-position. You can defeat funky town by setting percentage-based stops and using background-size. Sometimes rounding errors (maybe?) or other kinda rendering funkiness happens. See the Pen AEymd by Chris Coyier ( on CodePen. Who says they have to be straight lines eh? Radial gradients can be repeating-linear-gradients(): /* Note the RADIAL */ Just to be clear, with repeating-linear-gradient() you are best off doing a -webkit-repeating-linear-gradient() as well as the unprefixed one, if you’re, you know, prefixing buy yourself which you shouldn’t. See the Pen oCpEu by Chris Coyier ( on CodePen. Or, just use repeating-linear-gradient(): background: repeating-linear-gradient( You could use the same method as above for vertical stripes too. If you wanted to get crazy, you could transform: rotate() some element with these straight stripes and cut off the overflow, in which to replicate diagonal stripes with deeper browser support. See the Pen uxJrf by Chris Coyier ( on CodePen. But you could kinda fake it, especially for straight stripes, by making a small rectangle of background via background-size, drawing the stripes in there, and having it repeat naturally like background-image does. Those browsers don’t support repeating gradients. There is a super old syntax for CSS gradients that used -webkit-gradient() (note the no “linear” or “radial”). Straight Stripes (slightly better browser support) See the Pen qfHmw by Chris Coyier ( on CodePen. It’s not like this perfect rectangle that has to line up and repeat, it’s just a set of drawing instructions that repeats. That’s part of the beauty of the repeating-linear-gradient(). See the Pen gaKyv by Chris Coyier ( on CodePen. Again multiple backgrounds allows this to all happen on the same element. You could reveal part of the image by making some stripes fully transparent and some fully opaque. See the Pen xhkpD by Chris Coyier ( on CodePen. Because of multiple backgrounds (and stacking order), you can do that all together on a single element: background: If you make the background a regular linear-gradient(), and then make half the stripes totally transparent using repeating-linear-gradient(), it can appear as if the stripes have gradients. See the Pen epfEc by Chris Coyier ( on CodePen. Rather than the very last color-stop being 100% (or nothing, which means 100%) it’s a fixed value. I thought I’d document some variations in one easy to reference place.ĭiagonal stripes are easy to pull off thanks to repeating-linear-gradient(): background: repeating-linear-gradient( CSS gradients via the background-image property really got our back. Stripes are pretty easy to do in CSS these days.
0 Comments
Read More
Leave a Reply. |