IE8 CSS selector ~ (tilde) addresses only first element

倖福魔咒の 提交于 2020-01-14 14:44:10

问题


IE 8 will address only the first tooltip element "a[data-tooltip="sk_5 …" instead the preceeding ones too.

The HTML:

<div class="skcontainer">
   <a class="specialClassifications classification classfication_6" href="/de/ueberuns/romantik-siegel" data-tooltip="sk_6"></a>
   <a class="specialClassifications classification classfication_9" href="/de/ueberuns/romantik-siegel" data-tooltip="sk_9"></a>
   <a class="specialClassifications classification classfication_112" href="/de/ueberuns/romantik-siegel" data-tooltip="sk_112"></a>
   <a class="specialClassifications classification classfication_8" href="/de/ueberuns/romantik-siegel" data-tooltip="sk_8"></a>
   <div class="sks sk_5"><span class="inner"><p>'Gelber Schlüssel' für Romantik Hotels &amp; Restaurants mit luxuriösem Angebot. Für Gäste, die höchste Ansprüche an Stil, Ambiente, Genuss und Gastlichkeit stellen.</p></span></div>
   <div class="sks sk_6"><span class="inner"><p>TEXT</p></span></div>
   <div class="sks sk_7"><span class="inner"><p>TEXT</p></span></div>
   <div class="sks sk_8"><span class="inner"><p>TEXT</p></span></div>
</div>

Here's the CSS:

.sks {visibility:hidden; position: absolute; z-index: 100}
a[data-tooltip]:before {content: ""; position: absolute; visibility: hidden}
a[data-tooltip]:hover:before, a[data-tooltip="sk_5"]:hover ~ .sk_5,
a[data-tooltip="sk_6"]:hover ~ .sk_6, a[data-tooltip="sk_7"]:hover ~ .sk_7,
a[data-tooltip="sk_8"]:hover ~ .sk_8, a[data-tooltip="sk_9"]:hover ~ .sk_9,
a[data-tooltip="sk_10"]:hover ~ .sk_10, a[data-tooltip="sk_11"]:hover ~ .sk_11 {visibility: visible}

Any (CSS only) ideas or hints? Thanks a lot!


回答1:


Because the tilde is a CSS3 selector, it is buggy in IE7 & 8. Consider using Modernizr as a way to bridge the gap between IE8's CSS2 capabilities and modern CSS3 selectors.

Edit based on the rest of the comments: If you're considering dropping support for IE8, check your analytics first to make sure too many people won't be affected. If the tilde selector + css tooltips aren't working, you should make sure to add a title to the links so people in IE can still see [admittedly ugly] tooltips.



来源:https://stackoverflow.com/questions/17108091/ie8-css-selector-tilde-addresses-only-first-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!