Css method to insert pictures in input: first set the child element in the div containing the input; then set the outer div positioning to relative; then set the span positioning to absolute; finally add the margin-left attribute to the input That’s it.

The operating environment of this tutorial: windows7 system, HTML5&&CSS3 version, Dell G3 computer.
Recommended: css video tutorial
css insert pictures into input
1. Set in the div containing input Child element
<div class="search">
<span></span>
<input type="text">
</div>2. Set the outer div positioning to relative
.search{
position: relative;
}3. Set the span positioning to absolute, and set the width, height and background image
.search > span{
position: absolute;
display: inline-block;
width: 20px;
height: 20px;
background: url(./search.png) no-repeat;
background-size: 80% 80%;
background-position: center;
}4. Add margin-left attribute to input.
.search > input{
width: 100%;
padding-left: 20px;
}5. Rendering

The above is the detailed content of How to insert pictures into input with css. For more information, please follow other related articles on the PHP Chinese website!
Using GitHub Template Repos to Jump-Start Static Site ProjectsApr 16, 2025 am 11:14 AMIf you’re getting started with static site generators, did you know you can use GitHub template repositories to quickly start new projects and reduce your
Static First: Pre-Generated JAMstack Sites with Serverless Rendering as a FallbackApr 16, 2025 am 11:06 AMYou might be seeing the term JAMstack popping up more and more frequently. I’ve been a fan of it as an approach for some time.
CSS-Tricks Chronicle XXXVIApr 16, 2025 am 10:58 AMThis is one of these little roundups of things going on with myself, this site, and the other sites that are part of the CSS-Tricks family.
Weekly Platform News: Emoji String Length, Issues with Rounded Buttons, Bundled ExchangesApr 16, 2025 am 10:46 AMIn this week's roundup, the string length of two emojis is not always equal, something to consider before making that rounded button, and we may have a new
Meeting GraphQL at a Cocktail MixerApr 16, 2025 am 10:43 AMGraphQL and REST are two specifications used when building APIs for websites to use. REST defines a series of unique identifiers (URLs) that applications use
Introducing Sass ModulesApr 16, 2025 am 10:42 AMSass just launched a major new feature you might recognize from other languages: a module system. This is a big step forward for @import. one of the most-used
How I Learned to Stop Worrying and Love Git HooksApr 16, 2025 am 10:41 AMThe merits of Git as a version control system are difficult to contest, but while Git will do a superb job in keeping track of the commits you and your
A Proof of Concept for Making Sass FasterApr 16, 2025 am 10:38 AMAt the start of a new project, Sass compilation happens in the blink of an eye. This feels great, especially when it’s paired with Browsersync, which reloads


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.






