javascript - Bootstrap 3 Tooltip removes image padding -


i have sequence of img tags bootstrap 3 tooltips appearing on them on hover. when hover on them, tooltip appears image padding removed , strings them together; see first , second screenshot:

original padding

broken padding

here code:

<img src="//minotar.net/helm/pommmes/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="pommmes" /> <img src="//minotar.net/helm/kittycaitie/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="kittycaitie" /> <img src="//minotar.net/helm/1stboss11111/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="1stboss11111" /> <img src="//minotar.net/helm/igalaxhd/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="igalaxhd" /> <img src="//minotar.net/helm/liamflaherty63/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="liamflaherty63" /> <img src="//minotar.net/helm/fields/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="fields" /> <img src="//minotar.net/helm/markogamez/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="markogamez" /> <script>     $(function(){         $('[data-toggle=tooltip]').tooltip({             trigger: 'hover'         })      }); </script> 

looks webkit rendering issue. original markup using contains inline elements , looks this:

<img src="//minotar.net/helm/pommmes/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="pommmes" /> <img src="//minotar.net/helm/kittycaitie/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="kittycaitie" /> <img src="//minotar.net/helm/1stboss11111/32" data-toggle="tooltip" tabindex="50" data-placement="top" title="1stboss11111" /> 

since img inline elements default browser respects whitespaces between them, including newlines. whitespaces rendered initial margin between images. consider "normal".

what happens when hover on image image gets wrapped div container, how bootstrap displays toolstips, since can't append tooltip element img creates wrapper container put tooltip there temporarily.

however div inserted between 2 inline elements breaks previous whitespace rendering , reason it's not reverted when wrapper removed.

the simplest fix init tooltips this:

$(function() {     $('[data-toggle=tooltip]').tooltip({         trigger: 'hover',         container: 'body'     }) }); 

which dictates bootsrap append tooltips body container instead of hovered element.

in demo below, try comment out container: 'body' , see how buggy behavior back.

demo: http://plnkr.co/edit/4btvakzp1qy1crs3q0ok?p=preview


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -