:before and :after pseudo elements on html tag is wonky in Chrome

前端 未结 1 1513
旧巷少年郎
旧巷少年郎 2021-01-12 04:40

I\'m trying to learn how to use the :before and :after pseudo elements. I\'m trying to add a black background to the bottom of the page as a sticky footer but it doesn\'t se

相关标签:
1条回答
  • 2021-01-12 05:02

    Your CSS should work as expected, as your pseudo-element should be drawn in the context of the initial containing block (the viewport, represented by the html element) anyway, which is exactly what Firefox is doing.

    Your particular issue was reported as a Chrome bug, but it hasn't been addressed. As a workaround, you can apply your pseudo-element to body instead:

    body:before {
        content: "";
        display: block;
        background-color: #000;
        width: 100%;
        height: 138px;
        bottom: 0px;
        position: absolute;
    }
    

    Depending on your layout, you may need to either keep your html rule or change it to body as well.

    0 讨论(0)
提交回复
热议问题