<style>
li{
width:100%;
}
li:first-child:nth-last-child(2),
li:first-child:nth-last-child(2){
width:50%;
}
li:first-child:nth-last-child(3),
li:first-child:nth-last-child(3)~li{
width:33.3%;
}
</style>
本文介绍了一种使用CSS对li元素进行响应式布局的方法。根据不同数量的li元素,调整其宽度以适应不同的屏幕尺寸。
<style>
li{
width:100%;
}
li:first-child:nth-last-child(2),
li:first-child:nth-last-child(2){
width:50%;
}
li:first-child:nth-last-child(3),
li:first-child:nth-last-child(3)~li{
width:33.3%;
}
</style>

被折叠的 条评论
为什么被折叠?