CSS

CSS Overview Selectors Declarations Rule Sets Comments Reset/Normalize Origin Importance Order Specificity Inheritance Cascade Layers Inline Styles Internal Styles External Styles @import Absolute Units Relative Units Dynamic Viewport Angle Units Time Units Frequency Units: Resolution Units Keywords Color Formats Color Functions & Spaces Background Color Background Image Background Repeat Background Position Background Size Background Attachment Background Shorthand Multiple Backgrounds Linear Gradients Radial Gradients Conic Gradients Font Family Font Size Font Weight Font Style Line Height Text Align Text Decoration Text Transform Letter Spacing Word Spacing Text Shadow Text Wrap Variable Fonts Content Box Padding Box Border Box Margin Box Box Sizing Property Margin Padding Border Outline Box Shadow Block Display Inline Display Inline Block Display Static Position Relative Position Absolute Position Fixed Position Sticky Position Top Element Position Right Element Position Bottom Element Position Left Element Position Z Index Flexbox Box Layout Display Flex Flex Direction Flex Wrap Justify Content Align Items Align Content Gap, Row Gap & Column Gap Flex Grow Flex Shrink Flex Basis Flex Shorthand Order Property Align Self Practical Applications CSS Grid Layout Grid Display Grid Template Columns Grid Template Rows Grid Template Areas Justify Items Grid Auto Columns Justify Self Nested Grids Responsive Web Design Min Width Max Width Orientation Logical Operators Pointer Hover Prefers Color Scheme Fluid Images Flexible Typography Viewport Width Advanced CSS Features Defining variables Using variables Scope & Inheritance of CSS Variables Property Value Fallback Practical Applications :Hover :Active :Focus :Focus Visible :Visited :Link :First Child :Last Child :Nth Child :Nth of Type :Empty :Checked :Disabled :Enabled :Valid :Invalid :Required :Has :Not :Is :Where ::Before Pseudo Element ::After Pseudo Element ::First Letter ::First Line ::Selection ::Marker CSS 2D Transformations CSS 3D Transformations Transform Origin Transform Style Backface Visibility Transition Property Transition Duration Transition Timing Function Transition Delay Transition Shorthand Ease Timing Function Linear Timing Function Ease In Timing Function Ease Out Timing Function Ease In Out Timing Function Cubic Bezier Function Animations (@keyframes) Defining @keyframes Animation Name CSS Animation Duration Animation Timing Function CSS Animation Delay CSS Animation Iteration Count Animations Direction CSS Animation Fill Mode CSS Animation Play State CSS Filter Blur CSS Filter Brightness CSS Filter Contrast() CSS Drop Shadow CSS Grayscale CSS Hue Rotate CSS Invert CSS Opacity CSS Saturate CSS Sepia Mix Blend Mode Background Blend Mode Object Fit & Object Position Scroll Snap Type Scroll Snap Align Scroll Padding Scroll Margin Scroll Triggered Animations JS Variables

Ease Timing Function


The ease timing function is the default value for the animation-timing-function and transition-timing-function properties in CSS. It creates an effect where the animation or transition starts slowly, accelerates in the middle, and then slows down towards the end. This creates a more natural-looking motion compared to a linear speed.


Example 1: Transitioning Width with ease

/* This div will change its width when you hover over it */
.box {
  width: 100px;
  height: 100px;
  background-color: steelblue;
  /* Specifies the transition effect */
  transition: width 2s ease;
}

/* On hover, the box will expand to 300px */
.box:hover {
  width: 300px;
}

Explanation:

This code applies a transition to the width property of the .box element. When a user hovers over the box, its width changes from 100px to 300px over two seconds, following the ease timing function for a smooth start and finish.


Example 2: Animating Position with ease

/* This div will move from left to right */
.mover {
  width: 50px;
  height: 50px;
  background-color: tomato;
  position: relative;
  /* Defines the animation properties */
  animation-name: slide-in;
  animation-duration: 3s;
  animation-timing-function: ease;
  animation-iteration-count: infinite;
}

/* Keyframes for the sliding animation */
@keyframes slide-in {
  from {
    left: 0px;
  }
  to {
    left: 200px;
  }
}

Explanation:

The .mover element is animated using the slide-in keyframes. The animation-timing-function is explicitly set to ease, causing the element to move 200 pixels to the right with a slow start, a faster middle, and a slow end over a three-second duration.


Example 3: Changing Opacity and Color

/* This button will fade in color and opacity */
.button {
  padding: 15px 30px;
  background-color: #f0f0f0;
  color: #333;
  border: none;
  /* Applying transition to multiple properties */
  transition: background-color 1s ease, color 1s ease;
}

/* The button's style on hover */
.button:hover {
  background-color: #333;
  color: #fff;
}

Explanation:

When hovering over the .button, both the background-color and color properties transition over one second. The ease function ensures this change happens gracefully, with a noticeable acceleration and deceleration in the color transformation.


Example 4: Rotating an Element

/* An icon that rotates on hover */
.icon {
  font-size: 50px;
  display: inline-block;
  /* Sets the transition for the transform property */
  transition: transform 1.5s ease;
}

/* Rotates the icon 360 degrees on hover */
.icon:hover {
  transform: rotate(360deg);
}

Explanation:

This example demonstrates the ease timing function on the transform property. When the user's cursor is over the .icon, it completes a full 360-degree rotation. The rotation starts and ends slowly, making the effect feel smooth and polished.


Example 5: Scaling a Card Component

/* A card that scales up on hover */
.card {
  width: 200px;
  height: 250px;
  background-color: white;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  /* Defines the transition for the scaling effect */
  transition: transform 0.5s ease;
}

/* Scales the card by 5% on hover */
.card:hover {
  transform: scale(1.05);
}

Explanation:

Here, the .card element scales up slightly when hovered over. The ease function applied to the transform property makes this scaling effect feel dynamic and responsive, rather than abrupt and linear.