penguin_cheng 2021-09-13 13:04 采纳率: 76.2%
浏览 37
已结题

求解决:section标签里的样式如何生效?

如下图代码,但颜色效果没有出来,只有div的尺寸,求帮助

img

img


```css
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>流式布局(百分比布局)</title>
    <style>
        section{
            width:100%;
        }
        section div {
            width: 100%;
            height: 400px;
        }
        section div :nth-child(1) {
            background-color:pink;
        }
        section div :nth-child(2) {
            background-color: plum;
        }
    </style>
    
</head>
<body>
    <section>
        <div>布局1</div>
        <div>布局2</div>
    </section>
</body>
</html>



  • 写回答

2条回答 默认 最新

  • 前端不释卷leo 前端领域新星创作者 2021-09-13 13:43
    关注

    伪类中间没有空格
    section div:nth-child(1) {
    background-color:pink;
    }
    section div:nth-child(2) {
    background-color: plum;
    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 9月21日
  • 已采纳回答 9月13日
  • 修改了问题 9月13日
  • 修改了问题 9月13日
  • 展开全部