国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

JS Input里添加小圖標的兩種方法

2024-05-06 16:40:51
字體:
來源:轉載
供稿:網友

我們在做網頁的時候,經常需要在input里面添加小圖標,那么這里就介紹比較常見的兩種方法。

方法一

將小圖標當做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 標簽插入

<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>

總結

以上所述是小編給大家介紹的JS Input里添加小圖標的兩種方法,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復大家的!


注:相關教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 左云县| 青河县| 师宗县| 安泽县| 应城市| 琼中| 高邮市| 南川市| 常宁市| 哈密市| 宜宾县| 大宁县| 建湖县| 中宁县| 涿鹿县| 兴义市| 西宁市| 和林格尔县| 昌吉市| 河东区| 梅州市| 合水县| 佛学| 东乌| 聂拉木县| 彩票| 长沙市| 泗水县| 新民市| 大安市| 咸丰县| 巩义市| 高青县| 广灵县| 黄冈市| 资源县| 渝中区| 桃园市| 柏乡县| 会东县| 红河县|