• About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us
AimactGrow
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing
No Result
View All Result
AimactGrow
No Result
View All Result

translateX() | CSS-Methods

Admin by Admin
June 28, 2026
Home Coding
Share on FacebookShare on Twitter


The CSS translateX() perform shifts a component horizontally by the required quantity. Particularly, it displaces a component to the correct or the left, relying on whether or not the worth is constructive or damaging.

.mum or dad:hover .field {
  remodel: translateX(50%);
}

Together with different remodel features, it’s used contained in the remodel property.

It’s outlined within the CSS Transforms Module Degree 1 draft.

Syntax

The translateX() perform has a easy syntax given as:

 = translateX(  )

Or, in plain English: Translate (or transfer) this component horizontally by this a lot.

Arguments

/*  */
translateY(80px) /* Factor strikes 80px to the underside */
translateY(-24ch) /* Factor strikes 24ch to the highest */

/*  */
translateY(50%) /* Factor strikes 50% of the component's peak downward */
translateY(-100%) /* Factor strikes 100% of the component's peak upward */

The translateX() perform takes a single  argument that specifies how far to maneuver the component and by which course, which may be both left (damaging) or proper (constructive).

The argument handed might be both a  or a :

  • : When it’s constructive, say 50px, the component strikes 50 pixels to the correct. Then again, within the case of -40ch, the component strikes 40 characters to the left.
  • : Percentages are relative to the component’s width. So, for a 400px-wide component, translateX(50%) strikes it 200px to the correct, whereas translateX(-50%) strikes it 200px to the left.

Primary utilization

We are able to use the translateX() perform to make components slide onto the webpage in a lot of methods. As an example, a sidebar that slides in from the left (or proper) when clicking a menu button. To realize this, we initially shift the sidebar fully off the web page:

.sidebar {
  remodel: translateX(-100%);
  transition: remodel 0.2s ease-in;
}

Then, with somewhat JavaScript, we will toggle an .open class at any time when the person clicks on the menu buttons. This strikes the sidebar again into the web page from the left:

.sidebar.open {
  remodel: translateX(0);
}

Instance: Infinite marquee

Marquees in internet improvement are data banner elements that scroll mechanically. On most web sites, they’re used to show firm logos, maybe sponsors or shoppers, or, as on this case, announce new arrivals on an e-commerce web site.

Just like the final instance, we will use the translateX() perform to easily scroll a marquee part:

.marquee-content {
  animation: marquee-scroll 20s linear infinite;
}

@keyframes marquee-scroll {
  0% {
    remodel: translateX(0);
  }
  100% {
    remodel: translateX(-50%);
  }
}

The marquee-scroll keyframes defines how the part scrolls from the beginning stage to the cease stage, the place the part is shifted by half its width in the direction of the left.

To make it scroll infinitely, the animation-iteration-count is about to infinite on the animation shorthand property.

Instance: Skeleton format animation

Skeletons loaders act as placeholders till the principle content material masses and replaces them, stopping sudden format shifts. They could be a static grey div of various sizes and styles of the unique content material, or we will make them extra attention-grabbing with a shimmer impact.

Empty boxes (with a solid color or gradient background) are used as a placeholder while content is being gradually loaded. Text content is loaded and displayed first, and images are loaded and displayed after that.

Utilizing the ::after pseudoelement, we will set a default remodel: translateX(-120%);, then use a shimmer animation to maneuver it by the .skeleton part infinitely.

.skeleton::after {
  content material: "";
  place: absolute;
  inset: 0;

  remodel: translateX(-120%);
  background: linear-gradient(90deg, clear, var(--skel-highlight), clear);
  animation: shimmer 1.15s linear infinite;
}

The shimmer keyframe interprets the pseudoelement from -120% (off the component from the left) to 120% (out of the web page on the correct), then begins once more

@keyframes shimmer {
  0% {
    remodel: translateX(-120%);
  }
  100% {
    remodel: translateX(120%);
  }
}

It doesn’t have an effect on different components

The translateX() perform, like different remodel features, doesn’t have an effect on the doc move. As an alternative, it visually displaces the translated component to a brand new place with out pushing the weather in its environment or those on the new place. Additionally, the area the component initially occupied stays reserved within the format as if it hadn’t moved in any respect.

/* Translated component */
.translated {
  place: absolute;
  high: 0;
  left: 0;

  remodel: translateX(80px);
}

Discover how the “Translated” component doesn’t trigger both the Field 1 or Field 3 components to shift when it strikes.

In contrast to margin which might set off reflows or shift neighboring components, translate solely modifications the place the component is visually rendered.

Points with pointer pseudo-classes

Utilizing translateX() straight on a pointer pseudo-classes like :hover can generally break interactions. In a scenario the place the component is translated far and it strikes away from the cursor, the :hover state will get misplaced, inflicting the component to snap again instantly to its unique place. On the preliminary place, the cursor is there, so it interprets once more, leading to a steady flickering loop.

A easy answer to that is to put the component to be translated in a mum or dad container, and apply the pseudo-class (:hover) to the mum or dad component, whereas the principle component takes the translate perform.

/* Drawback case */
.unhealthy:hover {
  remodel: translateX(160px);
}

/* Answer */
.mum or dad:hover .good {
  remodel: translateX(160px);
}

Specification

The CSS translateX() perform is outlined within the CSS Transforms Module Degree 1, which is presently in Editor’s Drafts.

Browser assist

The translateX() perform has baseline assist on all trendy browsers.

Associated

Tags: CSSTrickstranslateX
Admin

Admin

Next Post
Invincible VS Devs Are Enthusiastic About Potential Mortal Kombat Crossover

Invincible VS Devs Are Enthusiastic About Potential Mortal Kombat Crossover

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

Anthropic Debuts Claude Code Safety

Anthropic Debuts Claude Code Safety

February 22, 2026
The Obtain: Saving the US local weather packages, and America’s AI protections are underneath risk

The Obtain: Saving the US local weather packages, and America’s AI protections are underneath risk

July 27, 2025

Trending.

Nsfw Chatgpt Options – Examples I’ve Used

Nsfw Chatgpt Options – Examples I’ve Used

October 13, 2025
Digital Detox & Display Time Statistics 2025

Digital Detox & Display Time Statistics 2025

March 28, 2026
How creators and entrepreneurs are utilizing AI to hurry up & succeed [data]

How creators and entrepreneurs are utilizing AI to hurry up & succeed [data]

June 17, 2025
Cisco Catalyst SD-WAN Zero-Day CVE-2026-20245 Exploited to Acquire Root Entry

Cisco Catalyst SD-WAN Zero-Day CVE-2026-20245 Exploited to Acquire Root Entry

June 25, 2026
All Overwatch 2 Dokiwatch Skins, Title Playing cards, And Cosmetics

All Overwatch 2 Dokiwatch Skins, Title Playing cards, And Cosmetics

April 24, 2025

AimactGrow

Welcome to AimactGrow, your ultimate source for all things technology! Our mission is to provide insightful, up-to-date content on the latest advancements in technology, coding, gaming, digital marketing, SEO, cybersecurity, and artificial intelligence (AI).

Categories

  • AI
  • Coding
  • Cybersecurity
  • Digital marketing
  • Gaming
  • SEO
  • Technology

Recent News

Invincible VS Devs Are Enthusiastic About Potential Mortal Kombat Crossover

Invincible VS Devs Are Enthusiastic About Potential Mortal Kombat Crossover

June 28, 2026
distinction() | CSS-Tips

translateX() | CSS-Methods

June 28, 2026
  • About Us
  • Privacy Policy
  • Disclaimer
  • Contact Us

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved

No Result
View All Result
  • Home
  • Technology
  • AI
  • SEO
  • Coding
  • Gaming
  • Cybersecurity
  • Digital marketing

© 2025 https://blog.aimactgrow.com/ - All Rights Reserved