Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7169043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:54:18+00:00 2026-05-28T14:54:18+00:00

I am trying to get a magnifying glass as the background for my input

  • 0

I am trying to get a magnifying glass as the background for my input element. The magnifying glass icon is part of a CSS sprite that looks like this:

enter image description here

To position it, I’ve used these properties:

#search-form input[type="text"] {
    background: url('../images/icons.png') no-repeat left center;
    background-position: 0px -30px;
    border: 1px solid #a9e2ff;
    padding: 3px;
    width: 200px;
    font-size: 1em;
    padding-left: 20px;
}

But the background still appears at the top of the input box rather than aligned in the vertical middle and to the left. I’ve also tried doing:

background: url('../images/icons.png') no-repeat left middle;

but that doesn’t work either.

If it matters, although I’m guessing it doesn’t, here’s my form markup:

<form action="/search" method="get" id="search-form">
    <input type="text" placeholder="Search..." name="s">
</form>

Thanks for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:54:19+00:00Added an answer on May 28, 2026 at 2:54 pm

    You declared background-position two times. The first one at the end of the background short-hand property, the second one on the next line. Solution: Split all single background rules like this (additionally, 0 -24px is the correct value):

    #search-form input[type="text"] {
        background-image: url('https://i.stack.imgur.com/MFpLm.png');
        background-repeat: no-repeat;
        background-position: 0 -24px;
        border: 1px solid #a9e2ff;
        padding: 3px;
        width: 200px;
        font-size: 1em;
        padding-left: 20px;
    }
    

    And now you can face the real problem with your design: other sprites will be visible in the input area if there are no sufficient space between them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get my css / C# functions to look like this: body {
I am trying get this background to fade in on click. I found one
I've this code that uses Savon that I'm trying get to work. require savon
Trying to get this expression to work, can someone look at it and tell
I am trying get the html within .event_recur. $(.entry).each(function(){ alert($(this).find(.event_recur).html()); }); <div class=entry> <p
Trying to get into PostgreSQL. I'm drawing an function that will check credentials Here
I am trying get my hands dirty with async CTP and I noticed that
I'm new to Drupal and trying get my head around it. I'd like to
I am trying get this ListView working and i'm trying to sort the list
I am trying get a div that I have hidden to show in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.