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 6229549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:35:16+00:00 2026-05-24T09:35:16+00:00

I can position a background image using the background property in an input field

  • 0

I can position a background image using the background property in an input field but I want an action to trigger when it is clicked.

Can I trigger an action on a background image click?

I just want to place a small ‘X’ image over the right hand side of input which clears the input.

  • 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-24T09:35:18+00:00Added an answer on May 24, 2026 at 9:35 am

    You can absolutely position a link over the <input> and then apply a text-indent to the <input> to make room for the image. For example:

    <div id="outer">
        <a href="javascript:void(0)" onclick="alert('click')"><img src="http://placekitten.com/16/16"></a>
        <input type="text">
    </div>
    

    And:

    #outer {
        position: relative;
    }
    #outer a {
        position: absolute;
        top: 0;
        left: 0;
    }
    #outer input {
        text-indent: 16px;
    }
    

    Live demo: http://jsfiddle.net/ambiguous/TgaFf/

    The outer <div id="outer"> is just there to give me something to apply position: relative to; absolutely positioned elements are positioned with respect to the nearest ancestor whose position is anything other than static. The text-indent on the <input> starts the input cursor 16px from the left side of the <input> and thus leaves space for the image. In the real world you would, of course, adjust the top, left, margins, paddings, … to make everything line up properly and look pretty.

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

Sidebar

Related Questions

The background-position property can be set in a variety of ways such as top
I was originally using the following code: background-image: url(../images/tabbottom.gif); background-repeat: no-repeat; background-position: left bottom;
Is there a way i can draw the black background behind the image using
How can I get the character at position 4 in a field? e.g. field
how can I set the mouse cursor position in an X window using a
I am trying to adjust the position of the background image of a button
I'm playing with the -webkit-mask-box-image css property. <div style= background-color: red; -webkit-mask-box-image: url('images/cards/set1.png'); ></div>
I am using the following script to animate a sprite for the background-image for
Heyo, I'm using a 2000px width image as a background for a 960px width
I'm trying to create a CSS3 button which includes an image using multiple background.

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.