javascript - css 选择器 - 选择第一个和最后一个之间的每个 div
问题描述
如何在容器中的第一个和最后一个 div 之后选择 div 元素,以便选择介于两者之间的所有内容
我的css中有这个
&--marker {
background: green;
width: 20px;
height: 20px;
border-radius: 100%;
position: absolute;
top: 50%;
transform: translate3d(0, -50%, 0);
&:first-child {
left: calc((100% / var(--index)));
}
// selector below doesn't work
&:nth-of-type():not(:first-of-type):not(:last-of-type) {
left: calc((100% / (var(--index) + 1)) - (var(--width)/2));
}
&:last-child {
left: calc((100% - var(--width));
}
}
解决方案
你可以试试这个:
.container div:not(:first-child):not(:last-child) {
/* css here */
}
推荐阅读
- angular - Angular 4,单元测试
- rust - 如何指定自定义 Cargo 输出目录?
- spotfire - 在 Spotfire 中应用 Over 函数时如何排除空值
- javascript - 如何使用 AJAX 将代码发送到数据库
- c# - 如何只运行一次浏览器
- mysql - Angular 4 与 nodejs 和 Mysql 连接
- typescript - 函数参数应该是对象的键类型之一
- python - Django 应用启动后仅运行一次命令
- networking - 禁止用户文件夹通过网络共享 Windows 10
- python - html 文件中的 {{ form }} 未呈现