Html5 Tooltip Via Css And Data- Field Works On Link But Not On Image
following the tutorial http://ejohn.org/blog/html-5-data-attributes/ I wanted to adapt the process of creating a tooltip for images (not links). So I adjusted the 'tooltip' class r
Solution 1:
You cannot use ::before/::after pseudo-elements on tags that cannot have children, i.e., <img>, <br>, <hr>, etc: MDN Documentation for :before
:beforecreates a pseudo-element that is the first child of the element matched.
Solution 2:
::beforecreates a pseudo-element that is the first child of the element matched.
<img> element is an empty tag not a container tag, you can't use ::beforepseudo-element on elements like <img>.
As an alternative, you can wrap the image by an inline wrapper element like <span>:
<spanclass="tooltip"data-tip="show a tooltip for image"><imgalt="show a tooltip for image"src="path/to/image" /></span>Solution 3:
Images do not allow for pseudo elements, thus setting a :before or :after on an <img> will not work.
Read for more info: CSS :after not adding content to certain elements
Post a Comment for "Html5 Tooltip Via Css And Data- Field Works On Link But Not On Image"