Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS link padding added via Javascript not working in IE
    primarykey
    data
    text
    <p>I tried searching for an answer first, but this seems to be an edge case.</p> <p>I'm adding a class to a link via JavaScript (well jQuery actually but I don't think it matters in this case). The class adds an icon as a background image and some padding. The padding and background image fail to appear on certain links. The problem shows up in IE8, but surprisingly works fine in IE7. I can't test IE9/10. Works fine in Firefox.</p> <p>I reduced the code down to a bare minimum and created a jsFiddle that illustrates the problem. <a href="http://jsfiddle.net/toxalot/fsdcu/" rel="nofollow">http://jsfiddle.net/toxalot/fsdcu/</a></p> <p>I'll try adding the code here.</p> <pre><code>&lt;style type="text/css"&gt; body { background-color: #fff } a:hover { background-color: transparent; color: #c30 } ul { padding-left: 40px } .iconNewWindowLeave { padding-right: 15px; background-color: #ccc } &lt;/style&gt; &lt;ul&gt; &lt;li style="float: left"&gt;&lt;a class="iconNewWindowLeave" href="#"&gt;left link&lt;/a&gt;&lt;/li&gt; &lt;li style="text-align: right"&gt;some stuff on the right&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li style="float: left"&gt;&lt;a class="linkExternal" href="#"&gt;left link&lt;/a&gt;&lt;/li&gt; &lt;li style="text-align: right"&gt;some stuff on the right&lt;/li&gt; &lt;/ul&gt; &lt;script type="text/javascript"&gt; $('.linkExternal').each(function() { $(this).addClass('iconNewWindowLeave'); }); &lt;/script&gt; </code></pre> <p>I've removed the image from the example and added a background color for illustration. In IE 8, the second link doesn't have right padding. Hovering over the link, adds the padding. If I remove the a:hover CSS, hovering doesn't correct the problem. If I remove the float, the problem goes away. If I remove any of the other CSS, the problem goes away.</p> <p>So I've narrowed down the cause(s), but I don't know what to do about it. I don't want to remove or change the existing code. It's all required for the site layout. If possible, I'd like to <em>add</em> some CSS or JavaScript to fix it. It's a minor issue, but it's bugging me. I'm also curious as to whether or not the problem appears in newer versions of IE.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload