這篇文章給大家分享的是有關css如何實現(xiàn)帶搜索圖標的搜索框功能的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
創(chuàng)新互聯(lián)建站專注于定興企業(yè)網(wǎng)站建設,成都響應式網(wǎng)站建設公司,商城網(wǎng)站建設。定興網(wǎng)站建設公司,為定興等地區(qū)提供建站服務。全流程按需網(wǎng)站開發(fā),專業(yè)設計,全程項目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務
前言
給大家分享一下前端用處很多的帶小圖標的搜索框的制作方法。
效果展示
基本思路
1、搜索圖像用絕對定位放到搜索框的上方
2、input框設置文本縮進,大小為搜索圖像大小加上圖像左右兩邊的外邊距
準備
只需一個搜索圖標圖片,類似于下圖
代碼
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>搜索框demo</title> <style type="text/css"> *{ margin: 0; padding: 0; } body{ width: 100vw; height: 100vh; background: radial-gradient(at center, #3498db,#2980b9); display: flex; justify-content: center; align-items: center; } div.search{ height: 40px; width: 500px; } div.search form{ width: 100%; height: 100%; } div.search form input:nth-child(2){ width: 400px; height: 100%; font-size: 16px; text-indent: 40px; border: none; float: left; } div.search form input:nth-child(3){ width: 100px; height: 100%; font-size: 16px; letter-spacing: 5px; border: none; } div.search form img{ position: absolute; left: 50vw; transform: translateX(-250px); margin-top: 10px; margin-left: 10px; height: 20px; } </style> </head> <body> <div class="search"> <form action="#" method="post"> <img src="./search_ico.png" alt=""> <input type="text" name="condition" placeholder="請輸入搜索條件"> <input type="submit" value="搜索"> </form> </div> </body> </html>
感謝各位的閱讀!關于“css如何實現(xiàn)帶搜索圖標的搜索框功能”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
本文標題:css如何實現(xiàn)帶搜索圖標的搜索框功能
標題網(wǎng)址:http://chinadenli.net/article12/gsgedc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供電子商務、網(wǎng)站導航、域名注冊、企業(yè)網(wǎng)站制作、小程序開發(fā)、微信小程序
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)