Q
Q
Qurds122021-04-28 18:36:25
css
Qurds12, 2021-04-28 18:36:25

How did text appear when hovering over svg?

How to make svg text appear on hover over

svg

<symbol id="flag-ru" width="20" height="12" viewBox="0 0 20 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg width="20" height="12" viewBox="0 0 20 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="20" height="4" fill="white"/>
<rect y="4" width="20" height="4" fill="#001AFF"/>
<rect y="8" width="20" height="4" fill="#FF0000"/>
</svg>
</symbol>


html

<div class="flag flag--ru">
      <svg>
         <use xlink:href="@/assets/svg/svg.svg#flag-ru"></use>
       </svg>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
postya, 2021-04-28
@Qurds12

data:() ({
hasText: false
})

meathods: {
showText() {
this.hasText = true
}

hideText() {
this.hasText = false
}
}

<div class="flag flag--ru" @mouseover="showText" @mouseleave="hideText">
      <svg>
         <use xlink:href="@/assets/svg/svg.svg#flag-ru"></use>
       </svg>
</div>

<p v-if="hasText">any text</p>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question