- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- 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 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 Tutorial
- CSS3 - Tutorial
- 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 - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - offset Property
The CSS shorthand property offset makes it easier for an element to animate along a certain path.
It has many characteristics that together comprise an offset transform.
With this transform, a specified point inside the element (offset-anchor) is aligned to a certain path position (offset-position) at various points along the route (offset-distance).
It also allows the element to be optionally rotated (offset-rotate) to follow the path's direction.
Constituent Properties
The offset property is a shorthand for the following CSS properties:
Possible Values
The following list of values is accepted by offset shorthand property.
offset-anchor - Defines a point within the element that aligns with an offset position on the path.
offset-path - Defines the path along which the element is animated.
offset-distance - Defines how far along the path the element is placed.
offset-rotate - Optionally rotates the element to align with the direction of the path.
auto - All properties are reset to their default values.
Applies to
Transformable elements
Syntax
offset = [ <'offset-position'>? [ <'offset-path'> [ <'offset-distance'> || <'offset-rotate'> ]? ]? ]! [ / <'offset-anchor'> ]?
CSS offset - path value
The following example demonstrates the usage of offset shorthand property with path value.
<html> <head> <style> @keyframes slide { 0% { offset-distance: 0%; } 100% { offset-distance: 100%; } } .container { width: 400px; height: 200px; border: 2px solid #3498db; border-radius: 10px; position: relative; overflow: hidden; background-color: #f0f0f0; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5); } .text { position: absolute; font-size: 28px; color: #3954cc; animation: slide 6s ease-in-out infinite alternate; offset: path('M 10 100 Q 50 50 90 100 T 170 100 T 250 100'); text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4); } </style> </head> <body> <div class="container"> <div class="text">This is Sliding Text</div> </div> </body> </html>
CSS offset - path and auto value
The following example demonstrates the usage of offset shorthand property with path and auto value.
<html> <head> <style> @keyframes orbit { 0% { offset-distance: 0%; offset-rotate: 0deg; } 100% { offset-distance: 100%; offset-rotate: 360deg; } } #planet { width: 60px; height: 60px; background-color: #0000A0; border-radius: 50%; position: absolute; animation: orbit 6s linear infinite; offset: path('M 200 200 m -100, 0 a 100,100 0 1,0 200,0 a 100,100 0 1,0 -200,0') auto; } #sun { width: 100px; height: 100px; background-color: #ffd700; border-radius: 50%; position: absolute; left: 28%; top: 33%; transform: translate(-50%, -50%); } </style> </head> <body> <div id="sun"></div> <div id="planet"></div> </body> </html>
CSS Offset - Related Properties
Following table lists related properties to offset property:
Property | Description |
---|---|
offset-anchor | Specifies the position inside an element's box that acts as the offset path. |
offset-distance | Specifies where element should be positioned. |
offset-path | Specifies element's path inside its parent container. |
offset-rotate | Specifies the orientation or direction of an element as it moves along the specified offset-path. |
offset-position | Provide an element's starting location along a route. |