
- 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 Function - cubic-bezier()
CSS cubic-bezier() function defines a custom cubic bezier curve for animations. It is used with the transition and animation to control the animation speed and smoothness. A Bezier curve smoothly connects points and helps to create a smooth animation by controlling the speed change.
Syntax
The syntax for the CSS cubic-bezier() function is as follows:
cubic-bezier(x1, y1, x2, y2);
Parameters
CSS cubic-bezier() function accepts four numeric values x1, y1, x2, y2. The x1 and x2 control the time progression whereas the y1 and y2 control the speed of the animation.
The range of x1 and x2 should be between 0 to 1 whereas the range of y can be any number.
Examples of CSS cubic-bezier() Function
The following examples illustrate the use of the CSS cubic-bezier() function.
Ease-In Effect with cubic-bezier() Function
In this example, we have used the CSS cubic-bezier() function to create an ease-in effect. In ease-in effect, animation starts slow and then speeds up.
Example
<!DOCTYPE html> <html lang="en"> <head> <title>Ease-In Effect with CSS cubic-bezier() Function</title> <style> .box { width: 50px; height: 50px; background: #04af2f; position: relative; animation: move 2s cubic-bezier(0.42, 0, 1, 1) infinite alternate; } @keyframes move { 0% { left: 0px; } 100% { left: 400px; } } </style> </head> <body> <h2>CSS cubic-bezier() Function</h2> <div class="container"> <div class="box"></div> </div> </body> </html>
Ease-Out Effect with cubic-bezier() Function
In this example, we have used the CSS cubic-bezier() function to create an ease-out effect. In the ease-out effect, the animation starts fast and then slows down.
Example
<!DOCTYPE html> <html lang="en"> <head> <title>Ease-Out Effect with CSS cubic-bezier() Function</title> <style> .box { width: 50px; height: 50px; background: #04af2f; position: relative; animation: move 2s cubic-bezier(0, 0, 0.58, 1) infinite alternate; } @keyframes move { 0% { left: 0px; } 100% { left: 400px; } } </style> </head> <body> <h2>CSS cubic-bezier() Function</h2> <div class="container"> <div class="box"></div> </div> </body> </html>
Ease-In-Out Effect with cubic-bezier() Function
In this example, we have used the CSS cubic-bezier() function to create an ease-in-out effect. In the ease-in-out effect, the animation starts slow then speeds up, and then finally slows down.
Example
<!DOCTYPE html> <html lang="en"> <head> <title>Ease-In-Out Effect with CSS cubic-bezier() Function</title> <style> .box { width: 50px; height: 50px; background: #04af2f; position: relative; animation: move 2s cubic-bezier(0.42, 0, 0.58, 1) infinite alternate; } @keyframes move { 0% { left: 0px; } 100% { left: 200px; } } </style> </head> <body> <h2>CSS cubic-bezier() Function</h2> <div class="container"> <div class="box"></div> </div> </body> </html>
Custom Effect with cubic-bezier() Function
In this example, we have used a custom combination of values.
Example
<!DOCTYPE html> <html lang="en"> <head> <title>Ease-In Effect with CSS cubic-bezier() Function</title> <style> .box { width: 50px; height: 50px; background: #04af2f; position: relative; animation: move 2s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite alternate; } @keyframes move { 0% { left: 40px; } 100% { left: 200px; } } </style> </head> <body> <h2>CSS cubic-bezier() Function</h2> <div class="container"> <div class="box"></div> </div> </body> </html>
CSS cubic-bezier() Function with Transition
In this example, we have used transition with the cubic-bezier() function to scale and change the background color of the button.
Example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Cubic Bezier Transition</title> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f4f4f4; } .btn { background-color: #031926; color: white; padding: 15px 30px; font-family: Verdana, sans-serif; border: none; border-radius: 8px; cursor: pointer; transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1), background-color 0.5s; } .btn:hover { transform: scale(1.3); background-color: #052c43; } </style> </head> <body> <button class="btn">Hover</button> </body> </html>
Supported Browsers
Function | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
cubic-bezier() | 16 | 12 | 4 | 6 | 12.1 |