HTML code to add icons to transparent input box

HTML code to add icons to transparent input box

I was recently writing a lawyer recommendation website, and there was a problem with the search box. I wanted to put the search icon inside the search box, but after a lot of work, I still couldn't get it to work...

Without further ado, let's get straight to the point:

Basic idea

In fact, just put the input box and the icon behind it in a div, then set border of the input box to 0px, and finally set border of the div to the final outer border

We directly go to the code:

HTML:

<div class="search">
        <form action="http://baidu.com">
           <input type="text" placeholder="Please enter the lawyer or expertise you are looking for">
               <span>
                 <a href="#"><img src="img/icon1.png" alt=""></a>
               </span>
          </form>
</div>

CSS:

Here is the style for the entire div outside

.search {
    width: 250px;
    height: 35px;
    border: 1px solid white;
    border-radius: 30px;
}

Here is to set the length and width of the input box, the frame is 0px, the font size inside, and the border will not light up when clicked (outline:none)
To set the transparency, use rgba() . The last attribute is the transparency (between 0 and 1).

input {
    width: 200px;
    height: 35px;
    border: 0;
    font-size: 14px;
    outline: none;
    background-color: rgba(255, 255, 255, 0);
    color: white;
    font-size: 16px;
    margin: 0 10px;

Summarize

This is the end of this article about the implementation code of adding icons in HTML transparent input box. For more relevant html transparent input box icon content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  Detailed explanation of how to use $props, $attrs and $listeners in Vue

>>:  CentOS 7 cannot access the Internet after modifying the network card

Recommend

Windows Server 2019 Install (Graphical Tutorial)

Windows Server 2019 is the latest server operatin...

Windows Server 2008 Tutorial on Monitoring Server Performance

Next, we will learn how to monitor server perform...

Advantages and disadvantages of conditional comments in IE

IE's conditional comments are a proprietary (...

Design Story: The Security Guard Who Can't Remember License Plates

<br />In order to manage the vehicles enteri...

Dynamic starry sky background implemented with CSS3

Result:Implementation Code html <link href=...

One sql statement completes MySQL deduplication and keeps one

A few days ago, when I was working on a requireme...

React Hooks Usage Examples

Table of contents A simple component example More...

WeChat applet records user movement trajectory

Table of contents Add Configuration json configur...

mysql solves time zone related problems

Preface: When using MySQL, you may encounter time...

Why is the disk space still occupied after deleting table data in MySQL?

Table of contents 1. Mysql data structure 2. The ...

Install Linux using VMware virtual machine (CentOS7 image)

1. VMware download and install Link: https://www....

Introduction to SSL certificate installation and deployment steps under Nginx

Table of contents Problem description: Installati...

Causes and solutions for front-end exception 502 bad gateway

Table of contents 502 bad gateway error formation...

Some suggestions for Linux system optimization (kernel optimization)

Disable swap If the server is running a database ...