Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Transitions and Transforms Getting Started with CSS Transitions Creating Your First Transition with transition-duration

Problem: Transition effects more than just the hover state

I'm struggling with this first video. I opened the workspace and copied the example. The hover effect works but I get an undesirable transition on the button element every-time the page reloads.

For example, when the page reloads the default button styles appear over a 1s duration. I do get the desired affect with the button but I only want this. I'm using Google Chrome as my browser.

Steven Parker
Steven Parker
217,602 Points

To allow replication of your issue, make a snapshot of your workspace and post the link to it here.

Hi Steven, link to workspace is here: https://w.trhou.se/6lxlnzi8k0

1 Answer

Steven Parker
Steven Parker
217,602 Points

This is a tricky one. One solution is to inhibit transitions before the page has loaded with this CSS:

.preload * { transition: none !important; }

And this HTML/script to enable them after loading:

<body class="preload" onload="document.body.className=null">

Okay, thank you! Do you know why this is happening? Is it a problem with my browser and did you have the same issue? Is this a common problem I need to be aware of? Appreciate your support as always :)

Steven Parker
Steven Parker
217,602 Points

It's common for this to happen (and with different browsers), but depending on what visual effect is involved, it's not always a "problem".