Jump to content
  • Announcements

    • boen_robot

      Guidelines and Netiquette   03/28/2017

      Posting Problems:   Having problems posting your topic? Read through this: To join, you agree to our terms and conditions and fill out and submit a registration form. An activation email will be sent to your email adress, so you'll need to verify your account. After that the account has to be validated by one of the moderators. This will mean that it can take up to a day to be activated. A couple of things to remember to ensure approval: Don't use an email address in one of those $2 four character .com domains eg. xyds.com. These will be deleted and the domain added to the banned list. Don't use an email address that is within a domain with a bad reputation for spam. A Google search is run on every email address and email domain. Don't sign up with an email address that doesn't exist, doesn't work or requires the sender to answer a quiz before their email can get to you. Put your country and or state and city in the signup form. Blank forms will go to the botton of the "to do" list. And make sure that your email address and your country match, saying you're from Alabama and using a .ru email address is not going to get you activated. After a membership is activated the first few posts will be monitored. Posting spam or unapproved topics described in the agreement results in an immediate ban. The email provider and the IP addresses associated with the account will be banned and all posts will be deleted. These strict measures have been deemed necessary to hinder spam. Sorry for any inconvenience this causes, but it's not liable to change. If, after reading this, you still can't post and don't understand why, contact one of the Moderators listed here.   Topic Guidelines   Including the following information can expedite an accurate response from board members: Must be a Specific Problem or Question related to web design and development Include Code in Question (wrap with   for small blocks of code and for longer blocks   ) Include Code Author Include Extra Notes/Modifications/Attempts Include web link to page/file when possible Content Guidelines   You may not post, upload, link to, or email any Content that contains, promotes, gives instruction about, or provides prohibited Content. Prohibited Content includes any Content that breaks any local, state, county, national or international law. Prohibited Content also includes: No direct or indirect advertising or websites, forums, products, services No hijacking of posts (do not post your question in someone elses) Content that infringes upon any rights [ex. MP3s and ROMs] (including, but not limited to, copyrights and trademarks) Abusive, threatening, defamatory, racist, or obscene Viruses or any other harmful computer software False Information or libel Spam, chain letters, or Pyramid schemes Gambling or Illicit drugs Terrorism Hacking or cheating for internet/online games Warez, Roms, CD-Keys, Cracks, Passwords, or Serial Numbers Pornography, nudity, or sexual material of any kind Excessive profanity Invasive of privacy or impersonation of any person/entity Hacking materials or information Posting Tips   There are more BBcodes than there are buttons for on the reply menu. To get the full list, click "BB Code Help" underneath the clickable smilie face menu. Use   for small snippets of code Use   for lengthy snippets of code Use   if your snippet is HTML (optional) Use   if your snippet is SQL (optional) Rules of Conduct   Be nice. There's no need for calling someone stupid if they ask an 'easy' question. Keep your avatars and signatures absolutely child friendly. We have a younger audience on this forum. Keep your language appropriate for the same reason above. Do not PM moderators for help on the forum. Post on the topic, or create a new one.   Spam:   Recently, as you have all without doubt noticed, we have had lots of spam and advertisement on the forum. Therefore, we'd like to alert you as to what to do when you have found any of the aforementioned annoying messages: it. Immediately. Give a clear reason, please, if the advertising is not evident. DO NOT POST! Report, let the post stay as is, and we will get to it, meanwhile if you continue to post as normal in the other threads, it won't be on the top so long. Refrain from PMing the member. This won't help at all, as they are most likely spambots anyway. Thank you.       Images in signatures:   After thinking of users on dial-up, we have decided to enforce the following rules regarding signatures. Please pay heed to them. Respecting these rules is respecting the members on this forum with dial-up. Signature rules: No animated images AT ALL. No matter the amount of animation. Maximum image widthxheight: 300x150 Maximum image (file) size: 15kb Use calm colors. Do not use highly contrasting images in your signature, as this can get really annoying when seeing several posts from one member in the same thread. The same prohibited content goes for images as for posts. Lastly, use common sense. No lengthy signatures please. Save us some scrolling. Thank you.       Links in signatures:   Please understand that w3schools.com only exists because of voluntary work and is barely supported by the advertising littered throughout the tutorials and the forum. So, please, stop advertising other sites. DO not post links that drive traffic away from the w3schools domain - especially to a site that offers similar if not identical information. Please help support the site by keeping individuals on it. Thank you. Here are some guidelines as to what you can put in your signature: w3schools links --> allowed w3.org links --> allowed browser links --> allowed html editor links --> allowed personal sites --> allowed tutorial sites competing with w3schools --> NOT allowed sites completely irrelevant to webprogramming and this forum --> NOT allowed   Thanks for understanding, and for taking the time to read this. ~W3Schools Modstaff~
ellenjones6

Problems with Tooltips

Recommended Posts

I need help solving two problems I am encountering with some tooltips that I created based on the W3Schools tooltip tutorial.  

Here is the page with the tooltips:  http://wildadirondacks.org/adirondack-wildflowers-starflower-trientalis-borealis.html 

Here is my html code for one of the paragraphs with tooltips: 

    <p>Starflower <strong>leaves</strong> vary considerably in size, from 1½ inches to about 4 inches  in length.</p>
      <ul>
        <li>Starflower leaves  are <div class="tooltip">lance-shaped<span class="tooltiptext"><img src="images/Lanceolate.jpg" alt="Lanceolate" title="Lanceolate">Lanceolate: A leaf shaped like a lance head, tapering to a point at each end.</span></div>
          , tapering to a tip. </li>
        <li>The leaves are arranged in a single <div class="tooltip">whorl
  <span class="tooltiptext"><img src="images/Whorled.jpg" alt="Whorled Leaf Arrangement" title="Whorled Leaf Arrangement">Whorled: Leaves arranged in a circle around a central point.</span>
</div> with 5 to 9 leaves (most commonly 7) near the top of the stem. </li>
        <li>The leaf edges are <div class="tooltip">smooth<span class="tooltiptext"><img src="images/Leaf-Margin-Smooth.jpg" alt="Smooth leaf margin" title="Smooth leaf margin">Smooth leaf edges do not have any teeth.</span></div>, with no or very fine teeth.</li>
        <li>
          <div class="tooltip">Leaf venation<span class="tooltiptext"><img src="images/Veins.jpg" alt="Veins of a leaf" title="Veins of a leaf">Leaf Venation: The arrangement of veins in a leaf.</span></div>
           is <div class="tooltip">pinnate<span class="tooltiptext"><img src="images/Pinnate-Leaf-Venation.jpg" alt="Pinnate Leaf Venation" title="Pinnate Leaf Venation">Pinnate Leaf Venation:  A vein arrangement in a leaf with one main vein extending from the base to the tip of the leaf and smaller veins branching off the main vein.</span></div>, meaning that there is one main <div class="tooltip">vein<span class="tooltiptext"><img src="images/Veins.jpg" alt="Veins of a leaf" title="Veins of a leaf">Vein: A vessel that conducts nutrients, sugars, and other substances throughout plant tissues; usually associated with leaves. The arrangement of veins in a leaf is called the venation pattern.</span></div> running from the base to the tip and secondary veins branching off at intervals.</li>
      </ul>

 

Here is my css code:  
 

        /* Tooltip container */
.tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
}

/* Tooltip text */
.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #000;
    color: #fff;
    text-align: left;
    padding: 5px;
    border-radius: 4px;
    font-size: 14px; 

    /* Position the tooltip text */
    position: absolute;
    z-index: 100;
    bottom: 100%;
    left: 50%; 
    margin-left: -100px;

    /* Fade in tooltip */
    opacity: 0;
    transition: opacity 1s;
}

/* Tooltip arrow */
.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: black transparent transparent transparent;
}

/* Show the tooltip text when you mouse over the tooltip container */
.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}
.tooltip img {
  float:left;
  margin:0px 8px 8px 0;
  width: 200px;
    border-radius: 4px;
}

 

I have two problems:

1.    The tooltips only work when they are inserted within an ordered list.  When I try to insert a tooltip in a paragraph, I get an unwanted line break.  I have fiddled around with the css, to no avail.  (I can provide a screen shot, if needed.)

2.    The tooltips as currently configured work fine on all six of my desktop browsers (Chrome, Firefox, Opera, Safari, Edge, Internet Explorer), opening as desired on mouseover.  The tooltips also work fine on two of the browsers on my iPad (Opera Mini and Firefox), opening on touch.  However, the tooltips do not work at all on the iPad in either Safari or Chrome; when I touch the target term, nothing happens.  I tried this out on some iPad emulators, and the tooltips worked, but they didn’t work on the actual iPad for either Safari or Chrome.  

Your tooltip examples work beautifully on all browsers on both my desktop and iPad, so it’s something I am doing wrong.  I have searched the forum for an answer, searched the internet, and fiddled around with the code for days, to no avail.  Please help!

Thanks, ellen
 

Share this post


Link to post
Share on other sites

IF it works in ipad with tutorial example, I would go through each of  your additional code and disabling with web developer tools or commenting out, try reinstating one at a time to identify the code which is causing the problem.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you so much for this suggestion!  It pointed me in the right direction, which is (as I understand it) to try to hold everything constant and start changing my code one piece at a time to try to identify what it is in my code that has been messing up my tooltips.  Before I did that, however, I decided to see whether I could replicate the problems I am encountering on my web site in a brand new page using the model code exactly as I got it from the tutorial and without any of my existing styles.  My logic:  if I could not replicate the problems on the test page, that would mean that it was either something (1) I had introduced when adjusting the tooltip code for my purposes, or (2) something in my style sheet that was fighting with the code from the tooltip tutorial.  If I was unable to replicate the problems, it would mean that I had to begin a process of trial and error to find out what in my code was messing up the tutorial code.  If I was able to replicate the problem, it would mean that it was something in the tutorial code.

Well, I created a brand new page that used the tooltip tutorial code.  That page is here:  http://wildadirondacks.org/Tooltip-Test.html

As you can see, the problems I have been struggling with on my Starflower page were EXACTLY replicated on the test page.

  1. Putting a tooltip in a paragraph resulted in an unwanted line.  Putting a tooltip in an unordered list worked fine.  (Same as in my Starflower page)
  2. The tooltips on the test page worked fine on my desktop (all six browsers) and on two of my iPad browsers (Opera Mini and Firefox).  The tooltips did not work at all on the iPad in either Chrome or Safari.  (I touched the target text and nothing happened.)

So, following the logic outlined above, I conclude that the problem is probably in the tutorial code.  I say "probably" because I might have unwittingly introduced something weird in the code when I cut and pasted into the test document.  This is not my area of expertise; I am primarily a researcher and writer and making unwitting (but fatal) errors while coding is a way of life for me.

Why does the tutorial code from the W3Schools site work on iPad on Chrome and Safari?  I don't know.  It may be something in the W3Schools style sheet.  Does the tutorial code work in plain old paragraphs for the tutorial pages on the W3Schools site?  I don't know, because I could not find an example  of a tooltip inside a para on the W3Schools site.  

So, despite your useful suggestion that led to this experiment, I am still in need of help.  

What can I do to the code on my Starflower page to make the tooltips work in (1) paragraphs (as well as unordered lists) and (2) in Chrome and Safari on my iPad? 

Ellen

Here is my html:

<body style="text-align:center;">

<h2>Tooltip</h2>

<div class="tooltip">Hover over me
  <span class="tooltiptext">Tooltip text</span>
</div>
        <p>This is paragraph one.  In this paragraph, I am just going to type for a while, to demonstrate what a paragraph looks using the body style in the example provided at W3Schols.  Just a plain old paragraph.  It's going to be centered on the page, because that's the style set up in the example I am following.  OK, now I am tired of typing, so I am going to end my pararaph. 
        </p>
    <p>This is paragraph two.  I am trying to see whether this tooltip will work inside a paragraph.  So I am just going to type and type and type, and then eventually insert a tooltip, followed by more typing.  Here is my tooltip: <div class="tooltip">Hover over me
  <span class="tooltiptext">Tooltip text</span>
</div>OK, now I am going to type a little bit more, to finish my fake paragraph.  As you can see, the tooltip inserts an unwanted line just before the tooltip target text.  The tooltip itself works, but it has messed up my paragraph.
        </p>
        
<p>Now, I am going to type in a second paragraph, followed by an unordered list, to see whether the tooltip will work with the unordered list: </p>
<ul>
          <li>          This is the first bullet of my unordered list.  </li>
          <li>This is the second bullet.  </li>
          <li>This is the third bullet. In this bullet, I am going to include a tooltip. Here is my tooltip: <div class="tooltip">Hover over me
  <span class="tooltiptext">Tooltip text</span>
</div> Thus ends my tooltip. </li>
          <li>This is the fourth bullet. </li>
</ul>
    <p>This is the rest of my paragraph.  I am going to type in a few more sentence to fill out the paragraph.  As you can see, the tooltip works perfectly inside an unordered list.  It does what a tooltip is supposed to do, and it doesn't insert an unwanted line. This test page mirrors exactly what my<a href="adirondack-wildflowers-starflower-trientalis-borealis.html"> Starflower page</a> did when I tried to inserts tooltip in a paragraph.  The tooltips inside an unordered list worked fine, but the tooltips inside a plain old paragraph inserted an unwanted line break. </p>
    <p>One additional point: When I deployed this page to the server, and tried it on my iPad, the tooltips behaved exactly as they behaved on my Starflower page.  That is, the tooltips appear obediently on touch with the Firefox and Opera Mini browsers, but do not appear at all with the Safari and Chrome browsers.  </p>
</body>
</html>

Here is my css:

<style>
.tooltip {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted black;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 1s;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}
</style>

 

Share this post


Link to post
Share on other sites

I don't have ipad so i can't test it.

I did notice that you have a block element div within a paragraph? THIS is NOT allowed, and being a block element it WILL force a new line. The only elements allowed in paragraph element are inline elements i.e span, strong, a (anchor) etc.

  • Like 1

Share this post


Link to post
Share on other sites

In that case, how can I create a tooltip within a paragraph, vice an unordered list?  I use a lot of unordered lists to present information on certain aspects of each plant, in part because usability studies advise doing so, to break up the text in chunks.  However, there are some cases where I would like to put a tooltip in the middle of a paragraph.  Is there a way to do that, without introducing an unwanted line break?  

Share this post


Link to post
Share on other sites

Use inline elements inside the paragraph, like  <span> instead of  <div>.

  • Like 1

Share this post


Link to post
Share on other sites

Well, that was easy!  Thank you so much!  You have solved the problem of tooltips within paragraphs.

I still need to solve the problem of the tooltips not working at all on my iPad on Chrome or Safari. Foxy, I know you don't have an iPad, but is there someone who does that can point me in the right direction?

Thanks again!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×