下拉菜单过渡

下拉过渡,利用Y轴的transform:scaleY(0) ---》transform:scaleY(1)

代码:

javascript 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
            background-color: #f4f4f4;
        }
        .text-select {
            width: 300px;
            /* background: #fff; */
            /* border-radius: 8px; */
            /* box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); */
            overflow: hidden;
            position: relative;
        }
        .text-select .text {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-bottom: none;
            /* border-radius: 8px 8px 0 0; */
            box-sizing: border-box;
            font-size: 16px;
            transition: border-color 0.3s ease;
        }
        .text-select .text:focus {
            border-color: #007BFF;
            outline: none;
        }
        .text-select .select {
            border: 1px solid #ddd;
            border-top: none;
            background: #fff;
            border-radius: 0 0 8px 8px;
            overflow: hidden;
            transform-origin: top;
            transform: scaleY(0);
            transition: transform 0.3s ease;
            z-index: 1;
        }
        .text-select .select span {
            display: block;
            padding: 10px;
            font-size: 14px;
            color: #333;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }
        .text-select .select span:hover {
            background-color: #f0f0f0;
        }
        .text-select .text:focus ~ .select {
            transform: scaleY(1);
        }
    </style>
</head>
<body>
    <div class="text-select">
        <input type="text" class="text" placeholder="Select an option..." />
        <div class="select">
            <span>Option 1</span>
            <span>Option 2</span>
            <span>Option 3</span>
            <span>Option 4</span>
            <span>Option 5</span>
        </div>
    </div>
</body>
</html>```
相关推荐
镜宇秋霖丶7 小时前
2026.5.6@霖宇博客制作中遇见的问题
前端·javascript·vue.js
Raytheon_code7 小时前
从零到一:我用微信小程序做了一款串珠DIY定制工具
css·微信小程序·html5·ai编程
吴声子夜歌7 小时前
Vue3——TypeScript基础
javascript·typescript
小李子呢02118 小时前
前端八股Vue---Vue-router路由管理器
前端·javascript·vue.js
百锦再9 小时前
Auto.js变成基础知识学习
开发语言·javascript·学习·sqlite·kotlin·android studio·数据库开发
洛_尘9 小时前
Python 5:使用库
java·前端·python
Bigger10 小时前
Bun 能上生产吗?我的实战结论
前端·node.js·bun
kyriewen11 小时前
你的前端滤镜慢得像PPT?用Rust+WebAssembly,一秒处理4K图
前端·rust·webassembly
kyriewen1111 小时前
你等的Babel编译,够喝三杯咖啡了——用Rust重写的SWC,只需眨个眼
开发语言·前端·javascript·后端·性能优化·rust·前端框架
IT_陈寒11 小时前
SpringBoot自动配置坑了我,原来要这样绕过去
前端·人工智能·后端