我們在做網(wǎng)頁的時(shí)候,經(jīng)常需要在input里面添加小圖標(biāo),那么這里就介紹比較常見的兩種方法。
方法一
將小圖標(biāo)當(dāng)做input的背景來插入,直接上代碼吧:
<style type="text/css">      *{        margin: 0;        padding: 0;      }      input{        border: none;      }      .box{        height: 50px;        background: yellow;      }      .box input{        width: 200px;        height: 30px;        border-radius: 15px;        margin: 10px 0;        background: url(image/search.gif) no-repeat;        background-color: white;        background-position: 3px;        padding-left: 30px;        border: 1px solid black;        outline: none;      }    </style>  </head>  <body>    <div class="box">      <input type="text" class="username" value="搜索"/>    </div>  </body>方法二
使用 i 標(biāo)簽插入
<style type="text/css">      *{        margin: 0;        padding: 0;      }      .box{        width: 200px;        position: relative;      }      .box .icon-search{        background: url(image/search.gif) no-repeat;        width: 20px;        height: 20px;        position: absolute;        top: 6px;        left: 0;      }      .box .username{        padding-left: 30px;        height: 25px;      }    </style>  </head>  <body>    <div class="box">      <i class="icon-search"></i>      <input type="text" class="username" value="搜索"/>    </div>  </body>總結(jié)
以上所述是小編給大家介紹的JS Input里添加小圖標(biāo)的兩種方法,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時(shí)回復(fù)大家的!
新聞熱點(diǎn)
疑難解答