第一个div设置class= box1 设置margin-right: auto; 为啥不生效
来源:4-9 子项分组布局

慕粉3725126
2022-01-23
老师 我给第一个div设置class= box1 设置margin-right: auto; 为啥不生效?
.box1 {
height: 50px;
margin-right: auto;
background: pink;
}
还是说只能用.main div:nth-of-type(1)
.main div:nth-of-type(1) {
margin-right: auto;
}
写回答
1回答
-
西门老舅
2022-01-24
您好,应该不是不生效。是你的选择器优先级不够导致的,你可以试一试 .main .box1 {}
00
相似问题