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 In Timing Function


The ease-in timing function is a value for the transition-timing-function property in CSS. It dictates that a transition or animation effect will begin at a slow pace and then progressively accelerate until it concludes. This creates a more dynamic and less robotic motion, perfect for elements that are starting an action.


Example 1: Width Expansion

/* This div will expand its width when hovered. */
.expand-box {
  width: 150px;
  height: 75px;
  background-color: #3498db; /* Initial blue color. */
  color: white;
  text-align: center;
  line-height: 75px;
  transition: width 2s ease-in; /* Defines the transition on the width property over 2 seconds with an ease-in effect. */
}

/* When the user hovers over the box, its width increases. */
.expand-box:hover {
  width: 300px; /* The final width of the element. */
}

Explanation When you hover your cursor over the blue box, its width animates from 150px to 300px. The ease-in function causes this expansion to start slowly and then gather speed, making the initial change subtle.


Example 2: Vertical Movement

/* The container that holds the moving element. */
.move-container {
  height: 200px;
  border: 2px solid #f0f0f0;
}

/* The element that will move downwards. */
.drop-down {
  width: 100px;
  height: 50px;
  background-color: #2ecc71; /* A green background color. */
  position: relative;
  top: 0;
  transition: top 2.5s ease-in; /* Applies the transition to the 'top' property. */
}

/* On hover of the container, the element moves down. */
.move-container:hover .drop-down {
  top: 150px; /* The final vertical position. */
}

Explanation In this example, hovering over the container causes the green box to move downwards. The ease-in value ensures the box starts its descent slowly, as if overcoming inertia, before accelerating towards its final position.


Example 3: Opacity Fade-In

/* The image will start as invisible. */
.fade-image {
  width: 200px;
  opacity: 0; /* Element is fully transparent initially. */
  transition: opacity 3s ease-in; /* Transition effect for the opacity property. */
}

/* When hovered, the image becomes fully visible. */
.fade-image:hover {
  opacity: 1; /* Element is fully opaque at the end of the transition. */
}

Explanation This code makes an image fade into view when you hover over it. The ease-in timing function makes the beginning of the fade-in very slow and gradual, after which it speeds up until the image is fully visible.


Example 4: Scale Transformation

/* The button element that will grow. */
.scale-up-button {
  padding: 15px 25px;
  background-color: #9b59b6; /* A purple background. */
  color: white;
  border: none;
  font-size: 16px;
  cursor: pointer;
  transition: transform 1.5s ease-in; /* Transition applied to the transform property. */
}

/* On hover, the button scales up in size. */
.scale-up-button:hover {
  transform: scale(1.2); /* Increases the size of the element by 20%. */
}

Explanation Hovering over this button will cause it to grow larger. The ease-in function dictates that the scaling animation starts slowly and then accelerates, giving the impression of the button "powering up".


Example 5: Border Color Change

/* A text input field that will change its border color on focus. */
.input-focus {
  padding: 10px;
  border: 3px solid #ccc; /* Initial grey border. */
  transition: border-color 2s ease-in; /* Transition for the border-color property. */
}

/* When the input field is in focus, the border color changes. */
.input-focus:focus {
  border-color: #e74c3c; /* A red border color on focus. */
  outline: none; /* Removes the default browser outline. */
}

Explanation When you click on the input field to type, its border color changes from grey to red. The ease-in timing function makes the initial phase of the color change happen slowly, with the color shift accelerating over the 2-second duration.