2012-05-03 9 views
4

画像とCSS擬似要素を使ってボックスの影とグラデーションの枠線を追加しようとしました。擬似要素を使ってレスポンシブ画像を追加する方法

私は、そのコードを試してみました:親のdivのサイズを変更したときに、それは手動で画像を追加することで機能し、一方、

.box:before { 
    content: url('box-shadow.png'); 
    position: absolute; 
    width: auto; 
    height: auto; 
    max-width: 100%; 
    z-index: -1; 
    bottom: -9px; 
    line-height: 0; 
} 
.box:after { 
    content: url('box-border.png'); 
    position: absolute; 
    width: auto; 
    height: auto; 
    max-width: 100%; 
    bottom: -5px; 
    right: 0px; 
} 

しかし、追加の画像は、サイズ変更されません。

私は私の側からしてみてくださいhttp://jsfiddle.net/5TG3E/2/

答えて

8

そのフィドルを参照してくださいそれはあなたを助けるだかもしれません。このように書く:偉大に見える

.box:after { 
    content:''; 
    position: absolute; 
    z-index: -1; 
    bottom: -9px; 
    margin: 0 auto; 
    top:0; 
    left:0; 
    right:0; 
    background:url('http://dl.dropbox.com/u/4812171/box-shadow.png') no-repeat bottom center; 
    -moz-background-size:100% 9px; 
    background-size:100% 9px; 
} 
.box:before { 
    content:''; 
    position: absolute; 
    bottom: 0px; 
    right: 0px; 
    left:0; 
    top:0; 
    background:url('http://dl.dropbox.com/u/4812171/box-border.png') no-repeat bottom right; 
} 

チェックこのhttp://jsfiddle.net/5TG3E/6/

+0

!ありがとうございました! – Laurent

関連する問題