<!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>
自动伸缩搜索框
于 2025-05-23 17:59:17 首次发布

被折叠的 条评论
为什么被折叠?



