
- CSS - Home
- CSS - Roadmap
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Types
- CSS - Measurement Units
- CSS - Selectors
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS - Cascading
- CSS - Universal Selectors
- CSS - ID Selectors
- CSS - Group Selectors
- CSS - Class Selectors
- CSS - Child Selectors
- CSS - Element Selectors
- CSS - Descendant Selectors
- CSS - General Sibling Selectors
- CSS - Adjacent Sibling Selectors
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Advanced Features
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS Interview Questions
- CSS Online Quiz
- CSS Online Test
- CSS Mock Test
- CSS - Quick Guide
- CSS - Cheatsheet
- CSS - Properties References
- CSS - Functions References
- CSS - Color References
- CSS - Web Browser References
- CSS - Web Safe Fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - repeating-linear-gradient()
In CSS, the function repeating-linear-gradient() is useful in creating an image, consisting of repeated linear gradients. The function is similar to linear-gradient(), as it takes the same arguments, where the color stops repeat itself infinitely in all the directions in order to fill the container. The resultant image is a special image, of <gradient> datatype.
Overview
The distance between the first and last color stop, determines the length of the gradient, that is repeated.
When the first color stop has no color-stop-length specified, it defaults to 0.
The positions of the color stops are shifted by a multiple of the length of basic linear gradient, with every single repetition.
If the color stop values are different, a clear visual transition can be seen between the color stops, as the ending color stop's position coincides with that of starting color stop.
A repeating-linear-gradient has no intrinsic dimensions, which means an image with no preferred size or aspect ratio.
The size of the image will match the size of the element it applies to.
The <gradient> datatype can be used only where <image>s are used.
The repeating-linear-gradient() function can not be used with <color> datatype and properties such as background-color.
Possible Values
The function repeating-linear-gradient() can have following values as arguments:
1. <side-or-corner>:
Determines the starting point of the gradient.
Contains the word to and upto two keyterms, ie., one indicates the horizontal side (left or right) and the other indicates the vertical side (top or bottom).
Order of the side keyterms can be anything.
When no value is specified, the default value set is to bottom.
Equivalent values to to top, to bottom, to left, and to right are 0deg, 180deg, 270deg, and 90deg respectively.
The <angle> value increases in a clockwise direction.
2. <linear-color-stop>: Consists of a color stop's <color> values, along with one or two optional values of stop positions. The stop position value can be either <percentage> or a <length> value. A value of 0% or 0, represents the start point of the gradient; whereas value of 100%, represents 100% of the image size when the gradient no more repeats.
3. <color-hint>: Determines the gradient progression between adjacent color stops. When no value specified, midpoint of the color transition is the midpoint between two color stops.
Syntax
repeating-linear-gradient( angle | to side-or-corner, color-stop1, color-stop2,...);
CSS repeating-linear-gradient() - Angle Value
Example of a repeating gradient tilted 60 degrees, with three color stops:
<html> <head> <style> div { height: 200px; width: 400px; } /* A repeating gradient tilted 60 degrees, with three color stops */ .repeat-linear { background-image: repeating-linear-gradient(60deg, red, yellow 7%, black 10%); } </style> </head> <body> <h1>Repeating linear gradient</h1> <div class="repeat-linear"></div> </body> </html>
CSS repeating-linear-gradient() - Bottom Right to Top Left
Example of a repeating gradient going from the bottom right to the top left.
<html> <head> <style> div { height: 200px; width: 400px; } /* A repeating gradient going from the bottom right to the top left */ .repeat-linear { background-image: repeating-linear-gradient(to left top, red, yellow 20px, black 20%); } </style> </head> <body> <h1>Repeating linear gradient</h1> <div class="repeat-linear"></div> </body> </html>
CSS repeating-linear-gradient() - Not Repeating
Example of a linear gradient where the gradient is not repeating as the last color stop defaults to 100%:
<html> <head> <style> div { height: 200px; width: 400px; } /* A gradient going from the bottom to top, starting red, turning yellow after 40%, and finishing green. This gradient doesn't repeat because the last color stop defaults to 100% */ .repeat-linear { background-image: repeating-linear-gradient(0deg, red, yellow 40%, green); } </style> </head> <body> <div class="repeat-linear"></div> </body> </html>