下拉菜单过渡

下拉过渡,利用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>```
相关推荐
捻tua馔...4 小时前
antd3的表单实现(HOC解决方案)
前端·javascript·react.js
支付宝体验科技4 小时前
支付宝 KJS Compose 动态化方案与架构设计
前端·客户端
AllinLin5 小时前
JS中的call apply bind全面解析
前端·javascript·vue.js
阿乐去买菜5 小时前
2025 年末 TypeScript 趋势洞察:AI Agent 与 TS 7.0 的原生化革命
前端
POLITE35 小时前
Leetcode 438. 找到字符串中所有字母异位词 JavaScript (Day 4)
javascript·算法·leetcode
创思通信5 小时前
STM32F103C8T6采 DS18B20,通过A7680C 4G模块不断发送短信到手机
javascript·stm32·智能手机
海绵宝龙5 小时前
Vue 中的 Diff 算法
前端·vue.js·算法
zhougl9965 小时前
vue中App.vue和index.html冲突问题
javascript·vue.js·html
止观止5 小时前
告别全局污染:深入理解 ES Modules 模块化与构建工具
javascript·webpack·vite·前端工程化·es modules
浩泽学编程5 小时前
内网开发?系统环境变量无权限配置?快速解决使用其他版本node.js
前端·vue.js·vscode·node.js·js