查看: 1067|回复: 0

通用好看的8款纯CSS3搜索框前端样式

[复制链接]

631

主题

436

回帖

80

日志

管理员

积分
5649
QQ
发表于 2024-5-3 05:04:24 | 显示全部楼层 |阅读模式

全部代码如下(最后提供了文件下载):

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>8款纯CSS3搜索框</title>
  7. <link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
  8. <style>
  9. * {
  10. box-sizing: border-box;
  11. }
  12. body {
  13. margin: 0;
  14. padding: 0;
  15. background: #494A5F;
  16. font-weight: 500;
  17. font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;
  18. }
  19. #container {
  20. width: 500px;
  21. height: 820px;
  22. margin: 0 auto;
  23. }
  24. div.search {padding: 30px 0;}
  25. form {
  26. position: relative;
  27. width: 300px;
  28. margin: 0 auto;
  29. }
  30. input, button {
  31. border: none;
  32. outline: none;
  33. }
  34. input {
  35. width: 100%;
  36. height: 42px;
  37. padding-left: 13px;
  38. }
  39. button {
  40. height: 42px;
  41. width: 42px;
  42. cursor: pointer;
  43. position: absolute;
  44. }
  45. /*搜索框1*/
  46. .bar1 {background: #A3D0C3;}
  47. .bar1 input {
  48. border: 2px solid #7BA7AB;
  49. border-radius: 5px;
  50. background: #F9F0DA;
  51. color: #9E9C9C;
  52. }
  53. .bar1 button {
  54. top: 0;
  55. right: 0;
  56. background: #7BA7AB;
  57. border-radius: 0 5px 5px 0;
  58. }
  59. .bar1 button:before {
  60. content: "f002";
  61. font-family: FontAwesome;
  62. font-size: 16px;
  63. color: #F9F0DA;
  64. }
  65. /*搜索框2*/
  66. .bar2 {background: #DABB52;}
  67. .bar2 input, .bar2 button {
  68. border-radius: 3px;
  69. }
  70. .bar2 input {
  71. background: #F9F0DA;
  72. }
  73. .bar2 button {
  74. height: 26px;
  75. width: 26px;
  76. top: 8px;
  77. right: 8px;
  78. background: #F15B42;
  79. }
  80. .bar2 button:before {
  81. content: "f105";
  82. font-family: FontAwesome;
  83. color: #F9F0DA;
  84. font-size: 20px;
  85. font-weight: bold;
  86. }
  87. /*搜索框3*/
  88. .bar3 {background: #F9F0DA;}
  89. .bar3 form {background: #A3D0C3;}
  90. .bar3 input, .bar3 button {
  91. background: transparent;
  92. }
  93. .bar3 button {
  94. top: 0;
  95. right: 0;
  96. }
  97. .bar3 button:before {
  98. content: "f002";
  99. font-family: FontAwesome;
  100. font-size: 16px;
  101. color: #F9F0DA;
  102. }
  103. /*搜索框4*/
  104. .bar4 {background: #F15B42;}
  105. .bar4 form {
  106. background: #F9F0DA;
  107. border-bottom: 2px solid #BE290E;
  108. }
  109. .bar4 input, .bar4 button {
  110. background: transparent;
  111. }
  112. .bar4 button {
  113. top: 0;
  114. right: 0;
  115. }
  116. .bar4 button:before {
  117. content: "f178";
  118. font-family: FontAwesome;
  119. font-size: 20px;
  120. color: #be290e;
  121. }
  122. /*搜索框5*/
  123. .bar5 {background: #683B4D;}
  124. .bar5 input, .bar5 button {
  125. background: transparent;
  126. }
  127. .bar5 input {
  128. border: 2px solid #F9F0DA;
  129. }
  130. .bar5 button {
  131. top: 0;
  132. right: 0;
  133. }
  134. .bar5 button:before {
  135. content: "f002";
  136. font-family: FontAwesome;
  137. font-size: 16px;
  138. color: #F9F0DA;
  139. }
  140. .bar5 input:focus {
  141. border-color: #311c24
  142. }
  143. /*搜索框6*/
  144. .bar6 {background: #F9F0DA;}
  145. .bar6 input {
  146. border: 2px solid #c5464a;
  147. border-radius: 5px;
  148. background: transparent;
  149. top: 0;
  150. right: 0;
  151. }
  152. .bar6 button {
  153. background: #c5464a;
  154. border-radius: 0 5px 5px 0;
  155. width: 60px;
  156. top: 0;
  157. right: 0;
  158. }
  159. .bar6 button:before {
  160. content: "搜索";
  161. font-size: 13px;
  162. color: #F9F0DA;
  163. }
  164. /*搜索框7*/
  165. .bar7 {background: #7BA7AB;}
  166. .bar7 form {
  167. height: 42px;
  168. }
  169. .bar7 input {
  170. width: 250px;
  171. border-radius: 42px;
  172. border: 2px solid #324B4E;
  173. background: #F9F0DA;
  174. transition: .3s linear;
  175. float: right;
  176. }
  177. .bar7 input:focus {
  178. width: 300px;
  179. }
  180. .bar7 button {
  181. background: none;
  182. top: -2px;
  183. right: 0;
  184. }
  185. .bar7 button:before{
  186. content: "f002";
  187. font-family: FontAwesome;
  188. color: #324b4e;
  189. }
  190. /*搜索框8*/
  191. .bar8 {background: #B46381;}
  192. .bar8 form {
  193. height: 42px;
  194. }
  195. .bar8 input {
  196. width: 0;
  197. padding: 0 42px 0 15px;
  198. border-bottom: 2px solid transparent;
  199. background: transparent;
  200. transition: .3s linear;
  201. position: absolute;
  202. top: 0;
  203. right: 0;
  204. z-index: 2;
  205. }
  206. .bar8 input:focus {
  207. width: 300px;
  208. z-index: 1;
  209. border-bottom: 2px solid #F9F0DA;
  210. }
  211. .bar8 button {
  212. background: #683B4D;
  213. top: 0;
  214. right: 0;
  215. }
  216. .bar8 button:before {
  217. content: "f002";
  218. font-family: FontAwesome;
  219. font-size: 16px;
  220. color: #F9F0DA;
  221. }
  222. </style>
  223. </head>
  224. <body>
  225. <div id="container">
  226. <div class="search bar1">
  227. <form>
  228. <input type="text" placeholder="请输入您要搜索的内容...">
  229. <button type="submit"></button>
  230. </form>
  231. </div>
  232. <div class="search bar2">
  233. <form>
  234. <input type="text" placeholder="请输入您要搜索的内容...">
  235. <button type="submit"></button>
  236. </form>
  237. </div>
  238. <div class="search bar3">
  239. <form>
  240. <input type="text" placeholder="请输入您要搜索的内容...">
  241. <button type="submit"></button>
  242. </form>
  243. </div>
  244. <div class="search bar4">
  245. <form>
  246. <input type="text" placeholder="请输入您要搜索的内容...">
  247. <button type="submit"></button>
  248. </form>
  249. </div>
  250. <div class="search bar5">
  251. <form>
  252. <input type="text" placeholder="请输入您要搜索的内容...">
  253. <button type="submit"></button>
  254. </form>
  255. </div>
  256. <div class="search bar6">
  257. <form>
  258. <input type="text" placeholder="请输入您要搜索的内容...">
  259. <button type="submit"></button>
  260. </form>
  261. </div>
  262. <div class="search bar7">
  263. <form>
  264. <input type="text" placeholder="请输入您要搜索的内容...">
  265. <button type="submit"></button>
  266. </form>
  267. </div>
  268. <div class="search bar8">
  269. <form>
  270. <input type="text" placeholder="请输入您要搜索的内容...">
  271. <button type="submit"></button>
  272. </form>
  273. </div>
  274. </div>
  275. </body>
  276. </html>
复制代码


上士闻道,勤而行之;中士闻道,若存若亡;下士闻道,大笑之。不笑不足以为道!
回复 关闭延时

使用道具 举报

您需要登录后才可以回帖 登录 | 注册  

本版积分规则

快速回复 返回顶部 返回列表