首頁 > web前端 > css教學 > 主體

如何使用 Bootstrap 新增圖示來搜尋輸入欄位?

Patricia Arquette
發布: 2024-11-13 15:06:02
原創
517 人瀏覽過

How to Add Icons to Search Input Fields with Bootstrap?

Search Input Field with Icon Bootstrap

In this modern era of Bootstrap 5 and beyond, customizing search input fields with icons has become a breeze. Let's dive into two primary approaches to incorporate icons into your search inputs.

Bootstrap 5 Beta

Bootstrap 5 provides us with the input-group class, which seamlessly integrates with input fields. Here's how you can use it:

<div class="input-group">
  <input class="form-control border-end-0 border rounded-pill" type="text" value="search">
登入後複製

Bootstrap 4 (Original Answer)

If you're working with Bootstrap 4, consider using the input-group class as well:

<div class="input-group col-md-4">
  <input class="form-control py-2" type="search" value="search">
登入後複製

Additional Options for Bootstrap 4:

  • Border Manipulation: Use Bootstrap utility classes like border-right-0 or border-left-0 to create inputs where the icon seemingly floats inside the field.
  • Input Group Text: Utilize input-group-text with a transparent background to achieve the same effect.
  • Grid System: Leverage the grid system (row and col) with no gutter spacing to create seamless transitions between the input and the icon.

以上是如何使用 Bootstrap 新增圖示來搜尋輸入欄位?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板