CSS将第一和最后一个子元素合并为一个div



css是否有办法将第一和最后一个子元素应用到一个div中?我希望第一个和最后一个子元素都具有相同的属性。

.productImageTable ul li:first-child{
text-align: center;
padding-top:40px;
font-size: 20pt;
}
.productImageTable ul li:last-child{
text-align: center;
padding-top:40px;
font-size: 20pt;
}

您的意思可能是-同时对第一个和最后一个子节点应用相同的规则。只要用逗号:

.productImageTable ul li:first-child, .productImageTable ul li:last-child {
text-align: center;
padding-top:40px;
font-size: 20pt;
}

相关内容

最新更新