8款纯CSS3搜索框

来源:互联网 发布:淘宝空间怎么登陆 编辑:程序博客网 时间:2024/06/05 11:32

效果图:



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