当我点击禁用的链接时,它会将我带到页面顶部。我为此做了什么不会发生?我用javascript代码尝试了它并且它不起作用,这个css也没有用。抱歉我的英文
.pagination ul {
display: inline-block;
padding: 0;
margin: 0;
}
.pagination li {
display: inline;
}
.pagination li a {
color: black;
float: left;
padding: 8px 16px;
text-decoration: none;
}
.pagination li.active a {
background-color: red;
color: white;
}
.pagination li:hover.active a {
background-color: red;
}
.pagination li:hover:not(.active) a {
background-color: #ddd;
color: black;
}
&.disabled,
&[disabled] {
cursor: not-allowed;
pointer-events: none; // Future-proof disabling of clicks
.opacity(.65);
.box-shadow(none);
}

<div class="container text-center">
<ul class="pagination">
<li class="disabled"><a href="">«</a></li>
<li class="active"><a href="index.html">1</a></li>
<li><a href="videos2.html">2</a></li>
<li><a href="videos2.html">»</a></li>
</ul>
</div>
&#13;
答案 0 :(得分:2)
您可以在class="disabled"
标记中使用a
,如下所示:
<强> HTML 强>
<ul class="pagination">
<li><a class="disabled" href="">«</a></li>
<li class="active"><a href="index.html">1</a></li>
<li><a href="videos2.html">2</a></li>
<li><a href="videos2.html">»</a></li>
</ul>
<强> CSS 强>
.disabled {
pointer-events: none;
}
答案 1 :(得分:1)
<ul class="pagination disabled"> // Add the disabled class to pagination
如果要禁用特定链接,请将禁用的类添加到要禁用的锚标记。
<a href="index.html" class="disabled"></a>
并将&amp; .disabled 修改为css中的 .disabled