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

  • Home
  • SEARCH
  • 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 6363287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:01:14+00:00 2026-05-25T00:01:14+00:00

I am currently working on an HTML, CSS, PHP project. I want to display

  • 0

I am currently working on an HTML, CSS, PHP project. I want to display a tooltip to provide a small explanation to the user when the user clicks on an input field on a form. I want the tooltip to appear next to the input field but overlaying the form slightly but instead when it appears it wraps around the edge of the form instead of continuing. I have tried changing the z-index for the tooltip to 1 but it hasn’t made any difference. The tooptip has been made with the use of HTML,CSS and JQuery. Below is the code that I have used to do this.

Below is the code for the form

<form action="index.php" method="post" style="margin-top: auto; margin-bottom: auto;">
    <table class="formTable">
         <tr><td>
    <label for="txtUsername">Username: </label>
    </td>
    <td>
           <input class="forms" type="text" name="txtUsername" placeholder="Username" required autofocus />
           <span class="tooltip" style="z-index: 1;">Please enter your username</span>
        </td>
        </tr>
        <tr>                    
            <td>
            <label for="txtPassword">Password: </label>
            </td>
            <td>
            <input class="forms" type="password" name="txtPassword" placeholder="Password" required /><br />
            </td>
            </tr>
            <tr><td colspan="2">
                <div class="buttonGroup">
                <input class="button" type="submit" name="btnSubmit" text="Submit" /> <input class="button" type="reset" text="Reset" />        </div>
            </td>
            </tr>
        </table>
       </form>

Below is CSS code for the form

form
{
    width: 500px;
    text-align: center;
    height: auto;
    background-color: #95b0ff;
    margin-left: auto;
    margin-right: auto;
    padding: 5px;
    border-width: 1px;
    border-color: black;
    border-style: solid;
    -webkit-border-radius:5px;
    -moz-border-radius:5px;
    border-radius:5px;
    z-index: 1;

}

Below is the CSS for the tooltip

.tooltip {
    padding: 5px;
    margin-left: 50px;
    background: #666;
    /*border: 1px solid #606060;*/
    border: 1px solid white;
    color: #ddd;
    -border-radius: 5px;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    box-shadow: 0 1px 3px #111;
    -moz-box-shadow: 3px 3px 1px #999;
    -webkit-box-shadow: 3px 3px 1px #999;
    z-index: 2;
 }

Below is the JQuery to show the tooltip

$(function() {
    $('.tooltip').hide();
    $('.tooltip').prev('input').focus(function(){
        $(this).next().fadeIn('slow');
    }).focusout(function(){
        $(this).next().fadeOut('slow');
    });
});

Thanks for any help you can provide.

UPDATE
Thanks to @Rikudo Sennin this has sort of worked. The only problem I have now is that the tooltip doesn’t appear next to the input field, instead it appears slightly underneath like in the image below

Form showing tooltip not aligned with 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-25T00:01:15+00:00Added an answer on May 25, 2026 at 12:01 am

    Use position: relative on the parent, and position: absolute on the tooltip.

    Working Example

    Also, on an unrelated note, for= attribute for <label>s searches for <input>s with matching id=s not name=s.

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

Sidebar

Related Questions

Working on an AJAX website (HTML,CSS,JavaScript, AJAX, PHP, MySQL). I have multiple javascript functions
I am currently working on a project and my goal is to locate text
I'm currently working on creating a new C# project that needs to interact with
I am currently working on a project with specific requirements. A brief overview of
I'm currently working at a small web development company, we mostly do campaign sites
The company I'm currently working for is using Selenium for Uniting-Testing our User Interface.
Web programmer here - using AJAX (HTML, CSS, JavaScript, AJAX, PHP, MySQL), but for
I'm working on a little html/css framework that I can use for most of
I'm currently working on refactoring a large amount of CSS, and a common trend
I'm working on a site currently which has a simple css nav menu with

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.