自动伸缩搜索框

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自动伸缩搜索框</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        
        body {
            font-family: 'Arial', sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: #f5f5f5;
            padding: 20px;
        }
        
        .search-container {
            width: 100%;
            max-width: 600px;
            position: relative;
        }
        
        .search-input {
            width: 50px;
            height: 50px;
            padding: 15px;
            border: none;
            border-radius: 25px;
            background-color: #fff;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            font-size: 16px;
            transition: width 0.4s ease, padding-left 0.4s ease;
            outline: none;
        }
        
        .search-input:focus {
            width: 100%;
            padding-left: 20px;
        }
        
        .search-btn {
            position: absolute;
            top: 0;
            right: 0;
            width: 50px;
            height: 50px;
            border: none;
            border-radius: 25px;
            background-color: #4285f4;
            color: white;
            cursor: pointer;
            transition: all 0.4s ease;
        }
        
        .search-input:focus + .search-btn {
            background-color: #3367d6;
        }
        
        .link {
            margin-top: 30px;
            text-align: center;
        }
        
        .link a {
            color: #4285f4;
            text-decoration: none;
        }
        
        .link a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="search-container">
        <input type="text" class="search-input" placeholder="搜索...">
        <button class="search-btn">
            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                <circle cx="11" cy="11" r="8"></circle>
                <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
            </svg>
        </button>
    </div>
    

</body>
</html>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值