Jonathan Ong
Jonathan Ong

Reputation: 20315

Make a box-shadow show over an adjacent floated element

http://jsfiddle.net/YQ6PU/

Right now, .link's background is above .main's box-shadow. How do I make it underneath?

In other words, nothing in .left should be on top of the box-shadow.

Ideas?

Upvotes: 3

Views: 1877

Answers (2)

Adrift
Adrift

Reputation: 59799

Add:

.link {
position: relative;
z-index: -10;
}

to the .link class

Upvotes: 6

Talha Akbar
Talha Akbar

Reputation: 10030

http://jsfiddle.net/YQ6PU/2/

body {
    background-color: #f8f8f8;
}

.left {
    float: left;
    width: 100px;
    height: 1000px;
}

.main {
    margin-left: 100px;
    height: 1000px;
    box-sizing: border-box;
    background-color: #fff;
    box-shadow: 0 2px 4px 2px rgba(0, 0, 0, .15);
}

.link {
    margin-top: 10px;
    display: block;
    background-color: #08C;
    position:relative;
z-index: -1;
}

@Perfect Dark said right!

Upvotes: 3

Related Questions