user1386906
user1386906

Reputation: 1179

Before and after of div do not display

I want to make an div that has cutoff corners. I want to do that with a :before and :after element with a background-image. There are positioned left and right of the div. But they do not display...

Here is my html:

<div class="page">
        <div class="canvas" id="canvas">
            <div class="TimeLineContainer">
                <div class="TimelineContent"></div>
            </div>

        </div>
    </div>

And this is the CSS iam using:

html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }

        body {
            font-size: 100%;
            font-family: "Calibri", Arial, sans-serif;
            color: black;
            text-align: center;
            overflow: hidden;
        }

        .page {
            display: block;
            text-align: left;
            width: 100%;
            height: 100%;
            position: relative;
            overflow: hidden;
        }

            .page .canvas {
                display: block;
                text-align: left;
                width: 100%;
                height: 100%;
                position: absolute;
                overflow: hidden;
                top: 0;
                left: 0;
            }

            .page .canvas .TimeLineContainer {
                display:block;
                width:100%;
                height:150px;
                text-align: center;
                overflow: hidden;
            }

                .page .canvas .TimelineContent {
                    display: block;
                    width:90%;
                    margin: 0 auto;
                    height:150px;
                    position: relative;
                    background-image: url(../img/middleTop.png);
                    background-repeat: repeat-x;
                    overflow: auto;
                }

                .page .canvas .TimeLineContainer .TimeLineContent:before {
                    position:absolute;
                    content:"";
                    top:0px;
                    left:-28px;
                    background-image: url (../img/cornerBL.png);
                    background-repeat: no-repeat;       
                    display: block;
                    width: 28px;
                    height: 150px;  
                }

                .page .canvas .TimeLineContainer .TimeLineContent:after {
                    position:absolute;
                    content:"";
                    top:0px;
                    right:-28px;
                    background-image: url (../img/cornerBR.png);
                    background-repeat: no-repeat;
                    display: block;
                    width: 28px;
                    height: 150px;  
                }

these are the images iam using:

cornerBL.png cornerBL.png

middleTop.png middleTop

and CornerBR.png cornerBR

I have really no idea why the before and after images are not displayed.

Here is a JSfiddle: http://jsfiddle.net/VWhPY/

Upvotes: 1

Views: 275

Answers (1)

Stephan Muller
Stephan Muller

Reputation: 27610

Try .page .canvas .TimeLineContainer .TimelineContent:after (notice the lowercase l in TimelineContent).

It still doesn't work properly, but that's the reason it's not showing up at all. Now you can continue debugging.

Another tip: set outline: thin solid red on your :before and :after elements while debugging to better see where they are without interfering with their box model.

Upvotes: 1

Related Questions