简体   繁体   中英

how to add css style and data-placement property=“top” for tooltips using the title attr- Javascript/CSS

I want to add a tooltip on hover over an icon, I want to it a simple way, I'm adding the title attribute to get the tooltip

html:

<div class="container">
<div class="block">

</div>
  <div class="row">
    <div title="hovered text"data-placement="top" class="tooltiptext">
    
      <span class="tooltips"onmouseover="hover(this)">
   Hola hover</span> 
    </div>
  </div>
    
</div>

http://jsfiddle.net/4sp1ufgn/

however I havent found a way yet to:

  1. style the tooltip using the title attribute
  2. the data-placement property does not work on title attribute.

even when I have value as "top" for data-placement, it still renders below the text. Any idea what would be the fix for the above 2 issues? Thanks in advance.

You can use the w3schools example, which is written only in HTML and CSS.

CSS Tooltip Example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM