\n

```

\n

How It Works:

\n

CSS Transitions: We apply a transition to smoothly change the background color. In this case, the box will smoothly transition its color when it reaches certain stages in the animation.

\n

CSS Animations: We use @keyframes to animate the box’s movement from left to right, changing its position and color at key stages (0%, 50%, and 100%).

\n

User Interaction: Clicking the button adds the animate class to the box, triggering the movement and color change. The animation takes 2 seconds to complete, and the background color smoothly transitions thanks to the transition property.

\n

This approach integrates both CSS transitions for smooth property changes and CSS animations for complex, multi-step movements. By combining them, you can create more engaging user interactions with minimal JavaScript, leveraging the power of CSS for visual effects.

\n

Happy coding!

\n

\n

🤙 the Slater Team

\n

\n

\n

If Slater helps you create better websites, please support the team behind it.

\n
Become a Pro Slater User
\n\n\n\n","recentPosts":[{"id":6835540,"title":"↩️ Undo better","slug":"undo-better","status":"published","readingTime":2,"campaignCompletedAt":"2024-10-04T19:40:26.000Z","publishedAt":"2024-10-04T19:40:26.000Z","orderByDate":"2024-10-04T19:40:26.000Z","timeAgo":"11 days","thumbnailUrl":"https://pbs.twimg.com/media/GZC11ZyXAAA7tGs.jpg","thumbnailAlt":"photo","path":"posts/undo-better","url":"https://slater.ck.page/posts/undo-better","isPaid":null,"introContent":"Do you get confused when undoing (cmd + z) in Slater? We auto-format your code on save. The auto-formatting updates your code, and those updates get pushed into the undo stack. You can now improve your workflow by formatting the code when you choose—not just on save. To gain more control over when your code formats: Turn off auto-format code in the Code Editor Settings Use cmd + shift + f to format your code We added a handful of other improvements: Console logs and debuggers are now...","campaignId":16777130,"publicationId":13318151},{"id":6630909,"title":"👩🏼‍🎨 Slater & CSS","slug":"slater-css","status":"published","readingTime":2,"campaignCompletedAt":"2024-09-13T21:35:19.000Z","publishedAt":"2024-09-13T21:35:19.000Z","orderByDate":"2024-09-13T21:35:19.000Z","timeAgo":"about 1 month","thumbnailUrl":"https://embed.filekitcdn.com/e/f2wTcXHNz6CCWc9a5vGTv3/xBjk9rMdaKBL8FStGReR65/email","thumbnailAlt":"","path":"posts/slater-css","url":"https://slater.ck.page/posts/slater-css","isPaid":null,"introContent":"Do you use Slater for CSS? CSS support in Slater has always been somewhat of an afterthought—JavaScript is our love language! But sometimes, you need a simple way to add CSS to your project. Maybe you want to write a complex grid or use a CSS property that Webflow doesn't support. That's why we've decided to make CSS a first-class citizen. We considered launching the new CSS functionality today, but we want to test it a bit more. Expect it early next week. To prepare for the launch, let's...","campaignId":16531524,"publicationId":13069812},{"id":6563182,"title":"👀 Project Access Controls","slug":"project-access-controls","status":"published","readingTime":2,"campaignCompletedAt":"2024-09-06T17:49:19.000Z","publishedAt":"2024-09-06T17:49:19.000Z","orderByDate":"2024-09-06T17:49:19.000Z","timeAgo":"about 1 month","thumbnailUrl":"https://pbs.twimg.com/ext_tw_video_thumb/1828456258979913728/pu/img/qlUwb6XebiOaDUPX.jpg","thumbnailAlt":"video","path":"posts/project-access-controls","url":"https://slater.ck.page/posts/project-access-controls","isPaid":null,"introContent":"You may recall that the original Slater had access controls for projects and files. We didn't want just anyone going in there and rewriting our Javascript. However, managing access for teammates became cumbersome (I even added a \"god mode\" to give myself access to any project or file). Since we generally trusted each other and never had issues, we decided to leave it out of the latest version of Slater. That said, we understand that some teams work differently, and maintaining control can be...","campaignId":16448819,"publicationId":12986765}],"newsletter":{"formId":4967504,"productId":null,"productUrl":null,"featuredPostId":null,"subscribersOnly":false},"isPaidSubscriber":false,"isSubscriber":false,"originUrl":"https://slater.ck.page/posts/smart-script-css","creatorProfileName":"Welcome To Slater!","creatorProfileId":1135261}👩🏼‍🎨 Smart Script CSS

👩🏼‍🎨 Smart Script CSS


Last week, we announced that CSS updates were on the way—and now they're here! You can now generate CSS files just as quickly and easily as JS files. In the video below, we give a quick demo of the new functionality. If you have a Smart Script loaded in your project, you can instantly add CSS.

In the demo, we also show how to add CSS in the Webflow designer. Give it a try and let us know what you're building!

video preview

Community Library

🖍️ Text Highlight Color
CSS code for custom text selection.

🅰 Improved Font Rendering
CSS for font smoothing, text rendering, and scroll behavior on the body element.

📗 Richtext Reset
Removes top margin of the first and bottom margin of the last child elements in a rich text container.

Have you added a useful script to your library? Share it with us!

--

Javascript 101: CSS & JS Part II

In the last Javascript 101, we explored how to modify styles with JavaScript to create dynamic websites. We looked at manipulating inline styles, toggling CSS classes, and updating CSS variables to respond to user input. Each approach gave us a different level of control over styling changes, and by keeping animations smooth and maintainable, we can create interactive user experiences.

Now, let’s combine what we learned last week with CSS transitions and animations. We’ll use CSS transitions for smooth property changes and @keyframes animations for more complex effects.

```
<style>
.box {
width: 100px;
height: 100px;
background-color: lightblue;
position: relative;
transition: background-color 0.5s ease; /* Transition for color changes */
}

@keyframes moveBox {
0% { left: 0; }
50% { left: 100px; background-color: tomato; } /* Color changes midway */
100% { left: 200px; background-color: skyblue; }
}

.animate {
animation: moveBox 2s forwards; /* Triggers the movement animation */
}

</style>

<button id="animateBtn">Animate Box</button>
<div id="box" class="box"></div>

<script>
const button = document.getElementById('animateBtn');
const box = document.getElementById('box');
button.addEventListener('click', () => {
box.classList.add('animate');
});
</script>

```

How It Works:

CSS Transitions: We apply a transition to smoothly change the background color. In this case, the box will smoothly transition its color when it reaches certain stages in the animation.

CSS Animations: We use @keyframes to animate the box’s movement from left to right, changing its position and color at key stages (0%, 50%, and 100%).

User Interaction: Clicking the button adds the animate class to the box, triggering the movement and color change. The animation takes 2 seconds to complete, and the background color smoothly transitions thanks to the transition property.

This approach integrates both CSS transitions for smooth property changes and CSS animations for complex, multi-step movements. By combining them, you can create more engaging user interactions with minimal JavaScript, leveraging the power of CSS for visual effects.

Happy coding!

🤙 the Slater Team

If Slater helps you create better websites, please support the team behind it.

Welcome To Slater!

Slater resources, updates and community activity

Read more from Welcome To Slater!
photo

Do you get confused when undoing (cmd + z) in Slater? We auto-format your code on save. The auto-formatting updates your code, and those updates get pushed into the undo stack. You can now improve your workflow by formatting the code when you choose—not just on save. To gain more control over when your code formats: Turn off auto-format code in the Code Editor Settings Use cmd + shift + f to format your code We added a handful of other improvements: Console logs and debuggers are now...

Do you use Slater for CSS? CSS support in Slater has always been somewhat of an afterthought—JavaScript is our love language! But sometimes, you need a simple way to add CSS to your project. Maybe you want to write a complex grid or use a CSS property that Webflow doesn't support. That's why we've decided to make CSS a first-class citizen. We considered launching the new CSS functionality today, but we want to test it a bit more. Expect it early next week. To prepare for the launch, let's...

video

You may recall that the original Slater had access controls for projects and files. We didn't want just anyone going in there and rewriting our Javascript. However, managing access for teammates became cumbersome (I even added a "god mode" to give myself access to any project or file). Since we generally trusted each other and never had issues, we decided to leave it out of the latest version of Slater. That said, we understand that some teams work differently, and maintaining control can be...