CSS3搜索框的設置可以通過多種方法實現(xiàn),以下是一些常見的設置方式:
1、使用HTML和CSS創(chuàng)建搜索框
HTML代碼:
<div class="search-box"> <input type="text" class="search-input" placeholder="請輸入搜索關鍵詞"> <button class="search-button">搜索</button> </div>
CSS代碼:
.search-box { width: 300px; height: 40px; border: 1px solid #ccc; border-radius: 5px; padding: 10px; } .search-input { width: 240px; height: 20px; border: none; border-radius: 3px; padding: 5px; } .search-button { width: 60px; height: 40px; border: 1px solid #ccc; border-radius: 5px; background-color: #f5f5f5; color: #333; font-size: 16px; line-height: 40px; text-align: center; }
2、使用CSS3的樣式設置搜索框
CSS代碼:
.search-box { position: relative; /* 搜索框相對于其他元素的位置 */ width: 300px; /* 搜索框的寬度 */ height: 40px; /* 搜索框的高度 */ border: 1px solid #ccc; /* 搜索框的邊框樣式 */ border-radius: 5px; /* 搜索框的圓角樣式 */ padding: 10px; /* 搜索框的內邊距 */ } .search-input { position: absolute; /* 輸入框相對于搜索框的位置 */ top: 0; /* 輸入框距離搜索框頂部的距離 */ left: 0; /* 輸入框距離搜索框左邊的距離 */ width: 240px; /* 輸入框的寬度 */ height: 20px; /* 輸入框的高度 */ border: none; /* 輸入框的邊框樣式 */ border-radius: 3px; /* 輸入框的圓角樣式 */ padding: 5px; /* 輸入框的內邊距 */ }
版權聲明:除非特別標注,否則均為本站原創(chuàng)文章,轉載時請以鏈接形式注明文章出處。