<div class="modalmenu" >
<div class="modal_itm" (mouseenter)="sepin(sepinout)" (mouseleave)="sepout(sepinout)"><a href="#in">HOME</a></div>
<div class="sep" #sepinout></div>
<div class="modal_itm" (mouseenter)="sepin(sepinout)" (mouseleave)="sepout(sepinout)"><a href="#ab">SOBRE MI</a></div>
<div class="sep" #sepinout></div>
<div class="modal_itm" (mouseenter)="sepin(sepinout)" (mouseleave)="sepout(sepinout)"><a href="#his">HISTORIA</a></div>
<div class="sep" #sepinout></div>
<div class="modal_itm" (mouseenter)="sepin(sepinout)" (mouseleave)="sepout(sepinout)"><a href="#ex">EXPERIENCIA</a></div>
<div class="sep" #sepinout></div>
<div class="modal_itm" (mouseenter)="sepin(sepinout)" (mouseleave)="sepout(sepinout)"><a href="#cont">CONTACTO</a></div>
<div class="sep" #sepinout></div>
</div>
export class NavBarComponent {
sepin(sepinout: HTMLElement){
sepinout.style.translate = "0px"
}
sepout(sepinout: HTMLElement){
sepinout.style.translate = "-2000px"
}
}
selector标签#sepinout只选择一个元素,我不知道如何同时选择多个元素,并且该函数对列表中的所有元素都有效
我尝试使用相同的选择器,但似乎不起作用,因为操作只发生在一个元素上
- 更新/解决方案**
<div class="modalmenu">
<span class="material-symbols-outlined nbcont_x">close</span>
<div class="modal_itm" (mouseenter)="sepin(sepinout)" (mouseleave)="sepout(sepinout)"><a href="#in">HOME</a></div>
<div class="sep" #sepinout></div>
<div class="modal_itm" (mouseenter)="sepin(sepinout1)" (mouseleave)="sepout(sepinout1)"><a href="#ab">SOBRE MI</a></div>
<div class="sep" #sepinout1></div>
<div class="modal_itm" (mouseenter)="sepin(sepinout2)" (mouseleave)="sepout(sepinout2)"><a href="#his">HISTORIA</a></div>
<div class="sep" #sepinout2></div>
<div class="modal_itm" (mouseenter)="sepin(sepinout3)" (mouseleave)="sepout(sepinout3)"><a href="#ex">EXPERIENCIA</a></div>
<div class="sep" #sepinout3></div>
<div class="modal_itm" (mouseenter)="sepin(sepinout4)" (mouseleave)="sepout(sepinout4)"><a href="#cont">CONTACTO</a></div>
<div class="sep" #sepinout4></div>
</div>
export class NavBarComponent {
sepin(sepinout: HTMLElement){
sepinout.style.translate = "0px"
}
sepout(sepinout: HTMLElement){
sepinout.style.translate = "-2000px"
}
}
1条答案
按热度按时间polhcujo1#
可以使用ViewChildren获取html的所有元素
类型脚本
希望对你有帮助