css - 使用 :not selector to exclude first and last child 的分页 CSS 上的点动画

标签 css css-selectors

我一直在研究一种新的分页样式,在数字上有一个点动画,但不是分页的第一个和最后一个 child ,但不确定我做错了什么。

如果我删除以下几行,动画将起作用,但第一个和最后一个子元素将不起作用。

.pagination a:before:not(:last-child),
.pagination a:before:not(:first-child),

.pagination a:hover:before:not(:last-child),
.pagination a:hover:before:not(:last-child),

代码

.paging-navigation {
	border-top: 1px solid rgba(0, 0, 0, 0.1);
	margin: 40px auto;
	padding-top: 30px;
	display: -webkit-box;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-pack: center;
	-ms-flex-pack: center;
	justify-content: center;
}
.pagination { font-family: Arial, Verdana, Sans-serif; line-height: 38px;}
.pagination a,
.pagination a:link,
.pagination a:visited,
.pagination a:active,
.pagination .current {
	position: relative;
	padding: 8px 12px;
	margin: 0 1px;
	font-size:14px;
	font-weight: bold;
	color: #444444;
	text-decoration: none;
}

.pagination a:before:not(:last-child),
.pagination a:before:not(:first-child),
.pagination a:before {
	content: '\2022';
	position: absolute;
	top: 0px;
	left: 0;
	right: 0;
	text-align: center;
	opacity: 0;
	transition: 300ms ease;
}
.pagination a:hover:before:not(:last-child),
.pagination a:hover:before:not(:last-child),
.pagination a:hover:before {
	content: '\2022';
	position: absolute;
	top: -20px;
	left: 0;
	right: 0;
	text-align: center;
	opacity: 1;
}
.pagination a:hover,
.pagination span.current { color: #444444; font-weight: bold; }
.pagination .current:before {
	content: '\2022';
	position: absolute;
	top: -20px;
	left: 0;
	right: 0;
	text-align: center;
}
.pagination .extend  { color: #919191; float: right; font-size: 11px; line-height: 35px;}
  <nav class="navigation paging-navigation">
    <div class="pagination loop-pagination">
      <a class="prev page-numbers" href="#"><i class="fa fa-angle-left fa-fw"></i>Previous</a>
      <a class="page-numbers" href="#">1</a>
      <a class="page-numbers" href="#">2</a>
      <span class="page-numbers current">3</span>
      <a class="page-numbers" href="#">4</a>
      <a class="next page-numbers" href="#">Next<i class="fa fa-angle-right fa-fw"></i></a>
    </div>
  </nav>

我做错了什么?可能是我在错误的方法中使用了 :not 选择器,或者不是作为 CSS 标准,但是当我使用 W3C 验证器验证 CSS 时,它验证了 100%

最佳答案

如果你想删除上一个和下一个链接上的点,那么你不需要使用伪类来定位它们。只需使用 a:not(.prev) 和 a:not(.next) 即可完成任务

关于css - 使用 :not selector to exclude first and last child 的分页 CSS 上的点动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47152197/

相关文章:

css - 如何使用 & 为列表中的一个特定选择器嵌套 scss 规则

javascript - vuetify.js v-select 最小高度限制?

css - 如何选择 ID 以特定字符串开头和结尾的所有元素?

ruby - nokogiri + 通过文本 Mechanize css 选择器

CSS :after, 内容 : having two values?

css - 我可以用类定义覆盖#id ul li 行为吗

jquery - 根据元素大小部分工作

javascript - 将浏览器的宽度设置为scss中的变量

css - 如何仅使用 css 更改 JStree 节点的图标?

python - 如何查找具有特定父元素的元素?