DreamTeK
DreamTeK

Reputation: 34217

Document flow of block level elements when using css :after pseudo selectors


TEST AREA

enter image description here

CSS

div{
    background:#59c;
    box-sizing: border-box;
    height: 100px;
    width: 100%;
    position: relative;
}
div:after{
    background:#b55;
    content: "I SHOULD BE AFTER CONTENT BOX";
    width: 100%;
    display:block;
}

Upvotes: 0

Views: 519

Answers (2)

web-tiki
web-tiki

Reputation: 103790

You can use absolute positioning for the pseudo element :

DEMO

div:after{
    position:absolute; /* <-- add this */
    top:100%; /* <-- and this */
    background:#b55;
    content: "I SHOULD BE AFTER CONTENT BOX";
    width: 100%;
    display:block;
}

Upvotes: 3

John
John

Reputation: 7900

This will work as you expect :

div {
    background:#59c;
    box-sizing: border-box;
    height: 100px;
    width: 100%;
    position: relative;
}
div:after {
    position: absolute;
    top: 100%;
    left: 0;
    background: #b55;
    content: "I SHOULD BE AFTER CONTENT BOX";
    width: 100%;
    display: block;
}

Upvotes: 1

Related Questions