- How TO — Search Bar
- Search Bar
- Create A Search Bar
- Example
- Example
- CSS Search Boxes
- Related Articles:
- Author
- Links
- Made with
- About a code
- Inspiration Search Bar
- Author
- Links
- Made with
- About a code
- Awesome Search Box
- Author
- Links
- Made with
- About a code
- Search Box
- Author
- Links
- Made with
- About a code
- Search Box Animation
- Author
- Links
- Made with
- About a code
- Search Input Caret Jump
- Author
- Links
- Made with
- About a code
- Search Box Animation
- Author
- Links
- Made with
- About a code
- Custom Search
- Author
- Links
- Made with
- About a code
- Search Animation — Only CSS
- Author
- Links
- Made with
- About a code
- Animated Search Interaction
- Author
- Links
- Made with
- About a code
- Skeuomorphic Search Input
- Author
- Links
- Made with
- About a code
- :placeholder-shown Selector
- Author
- Links
- Made with
- About the code
- Search Box Version 2
- Author
- Links
- Made with
- About the code
- Search Box Focus Effect
- Author
- Links
- Made with
- About the code
- Search Input Animation
- Author
- Links
- Made with
- About the code
- Pure CSS Animated Search Bar
- Author
- Links
- Made with
- About the code
- Search Form With Animated Search Button
- Author
- Links
- Made with
- About the code
- Expandable Search Bar Animation
- Author
- Links
- Made with
- About the code
- Pure CSS Expanding Search
- Author
- Links
- Made with
- About the code
- Search Bar
- Author
- Links
- Made with
- About the code
- Search Box
- Author
- Links
- Made with
- About the code
- Animated Search Input
- Author
- Links
- Made with
- About the code
- Expanding Input
- Author
- Links
- Made with
- About the code
- Increasing Input
- Author
- Links
- Made with
- About the code
- Simple On-click Search Field Interaction
- Author
- Как создать поле поиска
- Пример
- Пример
- Пример
- Пример
How TO — Search Bar
Learn how to add a search box inside a responsive navigation menu.
Search Bar
Create A Search Bar
Step 1) Add HTML:
Example
Step 2) Add CSS:
Example
/* Add a black background color to the top navigation bar */
.topnav overflow: hidden;
background-color: #e9e9e9;
>
/* Style the links inside the navigation bar */
.topnav a float: left;
display: block;
color: black;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
>
/* Change the color of links on hover */
.topnav a:hover background-color: #ddd;
color: black;
>
/* Style the «active» element to highlight the current page */
.topnav a.active background-color: #2196F3;
color: white;
>
/* Style the search box inside the navigation bar */
.topnav input[type=text] float: right;
padding: 6px;
border: none;
margin-top: 8px;
margin-right: 16px;
font-size: 17px;
>
/* When the screen is less than 600px wide, stack the links and the search field vertically instead of horizontally */
@media screen and (max-width: 600px) .topnav a, .topnav input[type=text] float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
>
.topnav input[type=text] border: 1px solid #ccc;
>
>
CSS Search Boxes
Welcome to our collection of CSS Search Boxes! In this collection, we have hand-picked a variety of free HTML and CSS search box code examples from popular platforms like CodePen, GitHub, and other reliable resources. This collection serves as an update to our June 2021 collection, featuring six new search box items.
Whether you’re looking for a simple search box or a more advanced and interactive design, you’ll find inspiration and practical examples here to enhance the search functionality on your website.
Related Articles:
Author
Links
Made with
About a code
Inspiration Search Bar
Animation for introducing a search bar on the page.
Compatible browsers: Chrome, Edge, Opera, Safari
Author
Links
Made with
About a code
Awesome Search Box
Awesome search box. Using only HTML & CSS.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Search Box
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Search Box Animation
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Search Input Caret Jump
A search input animation in which the magnifying glass handle flies off, becomes a caret, and plants itself into the field.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Search Box Animation
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Custom Search
Custom CSS search box with shadow and smoke text.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Search Animation — Only CSS
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Animated Search Interaction
A search animation where the head of the magnifying glass becomes the field and the handle grows into a search button. HTML5 validation of non-blank input ensures the field stays open when tabbing to the Search button.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Skeuomorphic Search Input
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
:placeholder-shown Selector
Trying out the :placeholder-shown selector to make a search form. With no JS, it validates and shows/hides the submit button.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Search Box Version 2
After learning the cubic-bezier function on CSS transition , I tried remaking the search box that I did before.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Search Box Focus Effect
Adding a thick outline on focus.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Search Input Animation
A small little pure CSS animation of search interaction.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Pure CSS Animated Search Bar
Animated seach box using pure HTML & CSS.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Search Form With Animated Search Button
Search form with animated search button which transforms into right arrow on hover.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Expandable Search Bar Animation
Hover effect for search bar in HTML & CSS.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Pure CSS Expanding Search
Pure CSS expanding search with custom properties.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Search Bar
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Search Box
Nice search box. Click on search icon, then type your keyword.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Animated Search Input
Animated (focus/transition only) search input that looks like a icon.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Expanding Input
A slighty different implementation of Keyframers version.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Increasing Input
Expanding search field with CSS.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Simple On-click Search Field Interaction
All the icons/images are made with CSS — the onlick interaction is done with the sibling selector ~ .
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Как создать поле поиска
Поля поиска распространены на каждой веб-странице. Они очень полезны при поиске конкретной информации. Поле поиска может иметь функцию ввода с автодополнением, что помогает пользователям при поиске.
В этой статье мы пошагово покажем, как можно создать поле поиска с помощью CSS и HTML.
form> input type="text" name=text" placeholder"Search here!"> input type="submit" name="submit" value="Search"> form>
Теперь у нас есть поле поиска, но необходимо добавить стиль.
Есть три элемента, к которым необходимо применить стиль: «form», «search» и»submit».
- Добавьте фоновый цвет текстовой части (body).
- Начните оформление классов «form», «search»и «submit».
- Установите width, margin, padding, и font-size.
После того, как все свойства добавлены, запустите код и увидите результат!
Пример
html> html> head> title>Заголовок документа title> style> body < background-color: #8ebf42; > form < width:400px; margin:auto; margin-top: 250px; > input< padding:4px 10px; border:0; font-size:16px; > .search < width: 75%; > .submit< width: 70px; background-color: #1c87c9; color:#ffffff; > style> head> body> h2>Создайте поле поиска h2> form> input type="text" name=text" class="search" placeholder"Search here!"> input type="submit" name="submit" class="submit" value="Search"> form> body> html>
Давайте создадим другие поля поиска:
Пример
html> html> head> link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> title>Поле поиска title> style> body < margin: 0; padding: 0; background: #00a08d; > .search-box < position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #666666; height: 40px; border-radius: 40px; padding: 10px; > .search-box:hover > .search-txt < width: 240px; padding: 0 6px; > .search-box:hover > .search-btn < background: white; color: black; > .search-btn < color: #eeeeee; float: right; width: 40px; height: 40px; border-radius: 50%; background: #2f3640; display: flex; justify-content: center; align-items: center; transition: 0.4s; color: white; cursor: pointer; text-decoration:none; > .search-btn > i < font-size: 20px; > .search-txt < border: none; background: none; outline: none; float: left; padding: 0; color: white; font-size: 16px; transition: 0.4s; line-height: 40px; width: 0px; font-weight: bold; > > style> head> body> div class="search-box"> input type="text" name="" class="search-txt" placeholder="Type to search"/> a class="search-btn" href="#"> i class="fa fa-search" aria-hidden="true"> i> a> div> body> html>
В данном примере мы использовали Search icon из Fontawesome.
Другой пример, где использованы только HTML и CSS:
Пример
html> html> head> link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> title>Заголовок документа title> style> body< background: #cccccc; > .search < width: 100%; position: relative; display: flex; > .searchTerm < width: 100%; border: 3px solid #9e0098; border-right: none; padding: 5px; height: 20px; border-radius: 5px 0 0 5px; outline: none; > .searchTerm:focus< color: #380136; > .searchButton < width: 40px; height: 36px; border: 1px solid #9e0098; background: #9e0098; text-align: center; color: #eeeeee; border-radius: 0 5px 5px 0; cursor: pointer; font-size: 20px; > .wrap< width: 30%; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); > style> head> body> h2>Создайте поле поиска h2> div class="wrap"> div class="search"> input type="text" class="searchTerm" placeholder="Type"> button type="submit" class="searchButton"> i class="fa fa-search"> i> button> div> div> body> html>
Рассмотрим еще один пример создания поля поиска:
Пример
html> html> head> title>Заголовок документа title> style> *, *::after, *::before < margin: 0; padding: 0; box-sizing: inherit; > html < font-size: 50%; > body < box-sizing: border-box; > .container < width: 25rem; height: 100%; margin: 0 1rem; position: relative; > h2 < margin: 2rem; font-size: 20px; > .searchbar < font-size: 2.4rem; width: 25rem; height: 5rem; border: none; outline: none; border-radius: 10rem; padding: 2rem; transition: all .1s; transition-delay: .1s; > .searchbar:hover < width: 27rem; height: 6rem; > .button < height: 2rem; position: absolute; top: 1.5rem; right: 1rem; transition: all .1s; transition-delay: .1s; > .button:hover < cursor: pointer; > .searchbar:hover + .button < height: 2.5rem; top: 1.8rem; right: 0; > .searchbar::placeholder < opacity: .3; > style> head> body> h2>Создайте поле поиска h2> div class="container"> input type="text" maxlength= "12" placeholder="Search" class="searchbar"> img src="https://images-na.ssl-images-amazon.com/images/I/41gYkruZM2L.png" alt="search icon" class="button"> div> body> html>