如何在悬停在悬停的DIV上进行宽度,这需要2秒钟的尾风CSS
我想对我的列中添加悬停效果,列将列宽。我尝试了使用或不带有尾风CSS的以下代码。 当悬停在任何DIV上时,变形时会立即发生。我希望过渡至少需要2秒才能完成。尾风CSS优先。谢谢。
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
colors: {
primary: '#5c6ac4',
secondary: '#ecc94b',
},
extend: { }
}
}
</script>
<style>
.custom-css {
transition: all;
transition-duration: 2s;
transition-timing-function: ease-in-out;
}
.custom-css:hover {
width: 100%;
}
</style>
</head>
<body>
<div class="flex column h-screen">
<div class="hover:w-full bg-primary transition-all duration-1000">hellow</div>
<div class="hover:w-full bg-secondary transition-all duration-1000">hellow</div>
<div class="hover:w-full bg-primary transition-all duration-1000">hellow</div>
<div class="hover:w-full bg-secondary transition-all duration-1000">hellow</div>
<div class="hover:w-full bg-primary transition-all duration-1000">hellow</div>
</div>
<div class="flex h-screen">
<div class="custom-css bg-primary ">hellow</div>
<div class="custom-css bg-secondary ">hellow</div>
<div class="custom-css bg-primary ">hellow</div>
<div class="custom-css bg-secondary ">hellow</div>
<div class="custom-css bg-primary ">hellow</div>
</div>
</body>
</html>
I want to add hover effect on my columns on which, the columns would expand in width. I tried the following code with and without tailwind-css.
When hover over any div, the transofrmation happen instantaneously. I want the transition to take at least 2 sec to finish. Tailwind CSS preferred. Thank you.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
colors: {
primary: '#5c6ac4',
secondary: '#ecc94b',
},
extend: { }
}
}
</script>
<style>
.custom-css {
transition: all;
transition-duration: 2s;
transition-timing-function: ease-in-out;
}
.custom-css:hover {
width: 100%;
}
</style>
</head>
<body>
<div class="flex column h-screen">
<div class="hover:w-full bg-primary transition-all duration-1000">hellow</div>
<div class="hover:w-full bg-secondary transition-all duration-1000">hellow</div>
<div class="hover:w-full bg-primary transition-all duration-1000">hellow</div>
<div class="hover:w-full bg-secondary transition-all duration-1000">hellow</div>
<div class="hover:w-full bg-primary transition-all duration-1000">hellow</div>
</div>
<div class="flex h-screen">
<div class="custom-css bg-primary ">hellow</div>
<div class="custom-css bg-secondary ">hellow</div>
<div class="custom-css bg-primary ">hellow</div>
<div class="custom-css bg-secondary ">hellow</div>
<div class="custom-css bg-primary ">hellow</div>
</div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了用 tailwind 解决此问题,您需要 flex-initial 类别,并且要悬停效应成长类。但是,如果您想将其用作自定义类,则应用 tailwind 实用程序将类包装。
To solve this with just Tailwind you need flex-initial class and for hover effect grow class. But if you want to use it as a custom class, you should wrap class with Tailwind utilities.