在我正在制作的网站中,我有一个部分包含加载不同图像的选项卡。我的问题是,如果您单击一个选项卡并再次单击,图像将再次加载,我不希望这种情况发生。仅在首先单击其他选项卡之一后再次加载。
这是我的 HTML:
<section id="vertical_tab_nav">
<ul>
<br><br><br>
<li id="#btnPro"><a href="index.html">Redes afectivas</a></li>
<li id="#btnPro" class="selected"><a href="index.html">Hooke</a></li>
<li id="#btnPro"><a href="index.html">Flizen</a></li>
</ul>
<div>
<article class="uno"></article>
<article class="dos"></article>
<article class="tres"></article>
</div>
</section>
这是用于更改图像的 CSS:
#vertical_tab_nav div article{
display: none;
margin: 0px;
color: #555;
transition: background 2s ease-out;
}
#vertical_tab_nav div .uno{
background-image: url(../img/solucion1.png);
background-repeat: no-repeat;
background-size: 90%;
margin: 0px;
margin-top: 0px;
color: #555;
min-height: 500px;
background-position: top;
margin-top: 10px;
}
除了背景图片外,三个选项卡的 CSS 相同
最佳答案
以这种方式添加 !important 关键字:
背景图片:url(../img/solucion1.png) !important;
阅读以获取更多信息:What does !important mean in CSS?
关于javascript - 重复单击按钮时防止再次加载标签图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56532478/