下拉菜单过渡

在这里插入图片描述
下拉过渡,利用Y轴的transform:scaleY(0) —》transform:scaleY(1)
代码:

<!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>```

相关推荐

  1. css实现二级导航菜单

    2024-07-23 02:34:04       48 阅读
  2. 表单进阶(4)-菜单

    2024-07-23 02:34:04       31 阅读
  3. html导航栏+菜单+表单验证

    2024-07-23 02:34:04       34 阅读
  4. Element-Plus Dropdown 菜单样式修改

    2024-07-23 02:34:04       35 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-23 02:34:04       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-23 02:34:04       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-23 02:34:04       45 阅读
  4. Python语言-面向对象

    2024-07-23 02:34:04       55 阅读

热门阅读

  1. objdump命令的常见用法

    2024-07-23 02:34:04       11 阅读
  2. 关于paddle OCR不能调用cpu的问题

    2024-07-23 02:34:04       14 阅读
  3. 数据结构代码

    2024-07-23 02:34:04       15 阅读
  4. 理解 Objective-C 中 `+load` 方法的执行顺序

    2024-07-23 02:34:04       17 阅读
  5. llama_index中使用Ollama是出现timed out 问题

    2024-07-23 02:34:04       18 阅读
  6. SSH连接虚拟机被拒绝

    2024-07-23 02:34:04       13 阅读
  7. 用python实现一个五子棋游戏,棋盘大小是20x20

    2024-07-23 02:34:04       15 阅读
  8. Leetcode 49. 字母异位词分组

    2024-07-23 02:34:04       15 阅读
  9. AOP面向切面编程的代码实现

    2024-07-23 02:34:04       16 阅读