簡體   English   中英

更改偽元素的樣式 ::after of an attribute

[英]Change style of the pseudo element ::after of an attribute

我正在創建一個簡單的工具提示系統,您可以在其中將屬性附加到元素: <div data-tooltip-content="testing out tooltip.">

(ps我用的是sass)

造型:

  content: attr(data-tooltip-content)
  color: white
  background: black
  padding: 5px
  position: absolute
  white-space: nowrap
  border-radius: .20rem
  margin-top: -2rem
  z-index: 14000 !important
  pointer-events: none

這些工具提示用於在卡片上顯示信息。 當用戶點擊這些卡片時,它們將展開和折疊。 但是當我現在做el.style['z-index'] = '0'; 在被點擊的卡片的 javascript 中。 然后工具提示被重疊,因為工具提示的 z-index 在 javascript 中被覆蓋,然后導致工具提示被其他具有更高 z-index 的東西重疊。 那么有沒有一種方法可以更改javascript中工具提示的樣式

您無法定位和操作偽元素,因為它實際上並不存在於 DOM 中。

但是您可以使用 javascript 注入樣式塊。 這可能會奏效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM