including a tooltip on the second background url within an HTML form input

Struggling with this issue for a few days now, I can't seem to find a good way to add a tooltip to the background url. In my case, I have two images in the background – a user icon on the far left and a help icon on the far right. I want to add a tooltip or title only when hovering over the tooltip.png icon located on the far right. Can anyone suggest a better approach to implement this?

Here is the code snippet:

input[type=text], input[type=p] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    background-color: #FFFFFF;
    display: inline-block;
    border: 1px solid #ccc;
    box-sizing: border-box;
    padding-left: 46px;
}
input[type=text] {
    background: url('https://cdn2.iconfinder.com/data/icons/windows-8-metro-style/512/user.png') 10px center no-repeat, url('http://visiblearea.com/blog/pub/System/JQueryPlugin/plugins/tooltip/tooltip-bubble-reverse.png') right 10px center no-repeat;
    background-size: 24px 24px, 15px, 15px;
    background-color: #FFFFFF;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Log In</title>
</head>
<body>
        <form id="loginform" onsubmit="return false;">
            <input type="text" id="email" placeholder="Username or Email" padding="10px">
        </form>
</body>
</html>

Any assistance would be greatly appreciated. Thank you!

Answer №1

input[type=text], input[type=p] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    background-color: #FFFFFF;
    display: inline-block;
    border: 1px solid #ccc;
    box-sizing: border-box;
    padding-left: 46px;
    z-index:-1;
}
input[type=text] {
    background: url('https://cdn2.iconfinder.com/data/icons/windows-8-metro-style/512/user.png') 10px center no-repeat;
    background-size: 24px 24px, 15px, 15px;
    background-color: #FFFFFF;
}
img{
  position:absolute;
  right:15px;
  top:20px;
}
#username{
position:relative;
}
.tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: black;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    position: absolute;
    right:15px;
    z-index: 1;
}

img:hover + .tooltiptext {
    visibility: visible;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sign In</title>
</head>
<body>
 
        <form id="loginform" onsubmit="return false;">
           <div id="username">
          <img src="http://visiblearea.com/blog/pub/System/JQueryPlugin/plugins/tooltip/tooltip-bubble-reverse.png" width=20px; height=20px;>
             <span class="tooltiptext">Please enter your username</span>
            <input type="text" id="email" placeholder="Username or Email" padding="10px">
          </div>
        </form>
    
</body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What impact does reducing the window size have on my header?

While working on a website with a navigation bar, I encountered an issue where the navbar was not responsive. When the window size was reduced, the nav bar shifted to an awkward position vertically, as shown in the first image. The navbar shifts below the ...

Issues with Font-Face Implementation

Hey there! I'm currently working on incorporating a new font into my website using font-face. However, it seems like something might be missing from my code because the style isn't being applied correctly. Here is what I have so far: <div id= ...

Is there a way to format this text horizontally?

Hey there, I'm trying to align the h4 with the p text. I attempted using display: inline-block, but it didn't do the trick. Can anyone lend a hand? Thanks in advance for any help! <h4>2.1</h4><p> Please refrain from blasphemy ...

Creating uniform heights for HTML column-based tables using divs in a React environment

I am developing a unique column-oriented and div-based table using React with Typescript. The data outside the table is organized in a column-based structure, rendering column 1 followed by row 1, row 2, row 3, then column 2 with its respective rows. The ...

Tips for arranging Bootstrap thumbnails in a horizontal row

Could someone assist me with arranging Bootstrap thumbnails side by side instead of vertically stacked? Any advice is appreciated! Here is the current code snippet for the two thumbnails: <div class="row"> <div class="col-sm-6 col-md-4"& ...

Using the getValue() method to retrieve the date

Snippet of HTML Code: <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">From</span> </div> @(Html.DevExpress().BootstrapDateEdit("dtReturnDateFrom").EditFormat(Edit ...

How can I resize the border to match the size of the text inside it?

Check out the following image to see how it appears:https://i.sstatic.net/RkMqI.png Here is an example code snippet of a message: .allMsg { width: 100%; } .self { border-radius: 1rem; background-color: #28a745; text-align: right; padding-lef ...

Moving smoothly while retaining absolute positioning

I have a question about a particular scenario. I have a div element that is styled like a ball and I want it to transition diagonally across the page to the bottom right corner instead of moving suddenly. However, this is not happening as expected. Can you ...

Issue with footer not properly aligning on the page's bottom

In my current project, I am utilizing both angularjs and node js for development. Within my index.html, the views are being called in the following manner: <div ng-include="'views/header/header.view.html'"></div> <div ng-view styl ...

What is the process for adjusting ASP.NET App_Themes according to the chosen Skin in RadSkinManager?

Is there a recommended way to dynamically change the ASP.NET App_Themes based on the selected skin in RadSkinManager? In my masterpage, I have a RadSkinManager dropdownlist that lets users choose their preferred skin from Telerik Rad Controls. I would lik ...

Ensure that the h2 text size is adaptable to mobile screens

Struggling to ensure my custom <h2> class remains responsive on mobile devices. My goal is to have this h2 class adjust to a text size of 49px when viewed on a mobile device. Here's what I have attempted so far: @media screen and (min-width: ...

Generate a see-through overlay when hovering over an image that matches the image's precise dimensions

I have encountered a challenge that I need help with. On a webpage, there are multiple images of varying sizes. I am looking to create a feature where hovering over an image triggers the appearance of a div above it containing a button and text without dis ...

Icons on Google Calendar events - Mini images beside your schedule

I'm in the process of developing a website where I plan to integrate Google Calendar. I want to include a small icon next to specific events to denote certain details. While the "categories" feature in Google Calendar allows me to assign highlight col ...

AngularJS enables the loading of directives dynamically, but sometimes encounters errors such as "Restricted URI access denied."

Presently, I am in the process of developing a small educational project using HTML5, CSS, JS and AngularJS. Hiccup: Loading an AngularJS Directive in my index.html file Error code [1] - Local browser Error: Access to restricted URI denied Various resp ...

The element is not occupying the full width within the div container

I'm working with a div that contains some elements. My goal is to have these elements span the entire width of the container div. .container { height: 100px; width: 100px; display: flex; flex-direction: column; overflow: scroll; borde ...

Tips for changing the dimensions of the canvas?

I'm struggling to display a photo captured from the webcam. The sizes are not matching up, and I can't pinpoint where the size is defined in the code. https://i.stack.imgur.com/Is921.png The camera view is on the left, while the photo should be ...

Encountered an issue when attempting to select the password field in order to log into a Google account using

Having some trouble automating the login process for my Gmail account. Managed to find the email element with an ID, but hitting a roadblock trying to locate the Password element as it doesn't have an ID. Here's what I've attempted: passw ...

I am attempting to center an image on a webpage while disregarding the margins set on the

Bar.html: <!DOCTYPE html> <head> <link rel="stylesheet" type="text/css" href="customStyle.css" /> </head> <body> The text formatting is spot on. Unfortunately, the following image should be centered, but it's off ...

The collapsible sidebar on my website was functioning perfectly with Bootstrap 5, but now it seems to

I've got this sidebar that is supposed to toggle when the button in the top right corner of the photo is clicked. Currently, it's not working even though it was working fine before. I'm not sure what the issue might be. Below is the HTML c ...

I am interested in toggling the visibility of two div elements

I am trying to create functionality where div 2 is displayed when div 1 is clicked, and div 1 is hidden. Then, when clicking on div 2, div 1 will appear again while div 2 disappears. My code attempts to achieve this behavior, but it doesn't seem to w ...