CSS3 在搜索图片方面提供了很多一个新特性,使得网页设计更加灵活多变,下面是一些关于 CSS3 搜索图片的方法和技巧:/ 实现搜索按钮点击放大效果 / .searchbtn:hover { tran...
CSS3 在搜索图片方面提供了很多一个新特性,使得网页设计更加灵活多变,下面是一些关于 CSS3 搜索图片的方法和技巧:
/* 实现搜索按钮点击放大效果 */
.search-btn:hover {
transform: scale(1.1);
transition: all .2s ease-in-out;
}
/* 使用伪类生成搜索框图标 */
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button {
display: none;
}
.search-input::-webkit-search-icon {
background-image: url(search.png);
background-size: 20px 20px;
background-repeat: no-repeat;
padding: 10px;
-webkit-appearance: none;
}
/* 使用 CSS3 伪元素实现搜索框前面的提示文字 */
.search-input::before {
content: "Search:";
font-size: 12px;
color: #999;
position: absolute;
left: 10px;
top: 8px;
}
/* 使用 CSS3 伪元素实现搜索结果列表的样式 */
.search-results::after {
content: "";
display: table;
clear: both;
}
.search-results li {
float: left;
margin: 5px;
width: 150px;
height: 150px;
overflow: hidden;
background-color: #f5f5f5;
border: 1px solid #ddd;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
transition: all .2s ease-in-out;
}
.search-results li:hover {
transform: scale(1.05);
box-shadow: 0 4px 4px rgba(0, 0, 0, 0.2);
}
.search-results a {
display: block;
width: 100%;
height: 100%;
} 通过使用上面的代码,您可以实现搜索按钮的跳跃放大效果、搜索框前面的提示文字、自定义的搜索框图标、搜索结果列表的样式等功能。这些都是 CSS3 搜索图片的一些简单技巧,希望可以对您有所帮助。