Preface Let me share with you how to make a search box with small icons which is very useful in the front end. Effect display Basic idea 1. Use absolute positioning to place the search image above the search box 2. Set the text indentation of the input box to the size of the search image plus the margins on the left and right sides of the image Prepare Just a search icon image, similar to the one below Code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Search box demo</title> <style type="text/css"> *{ margin: 0; padding: 0; } body{ width: 100vw; height: 100vh; background: radial-gradient(at center, #3498db,#2980b9); display: flex; justify-content: center; align-items: center; } div.search{ height: 40px; width: 500px; } div.search form{ width: 100%; height: 100%; } div.search form input:nth-child(2){ width: 400px; height: 100%; font-size: 16px; text-indent: 40px; border: none; float: left; } div.search form input:nth-child(3){ width: 100px; height: 100%; font-size: 16px; letter-spacing: 5px; border: none; } div.search form img{ position: absolute; left: 50vw; transform: translateX(-250px); margin-top: 10px; margin-left: 10px; height: 20px; } </style> </head> <body> <div class="search"> <form action="#" method="post"> <img src="./search_ico.png" alt=""> <input type="text" name="condition" placeholder="Please enter the search condition"> <input type="submit" value="Search"> </form> </div> </body> </html> Summarize The above is the search box function with search icon based on HTML CSS introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! |
<<: Several navigation directions that will be popular in the future
>>: MySQL group query optimization method
This article uses an example to describe how to u...
Table of contents 1. What is an event? 2. How to ...
Table of contents The creation and confusion of n...
By default, the width and height of the table are...
This article introduces the implementation code o...
Component Basics 1 Component Reuse Components are...
The key features of the InnoDB storage engine inc...
This blog is a work note environment: nginx versi...
When joining a Windows 2008 server subdomain to a...
Since its launch in 2009, flex has been supported...
Nowadays, application development is basically se...
Redis is an open source NoSQL database written in...
In fact, this problem has already popped up when I...
Table of contents Overview Install Gulp.js Create...
This article introduces Nginx from compilation an...