1

画像を表示する img タグがあります。これはうまくいきます。同じファイルに、同じ URL と同じファイルを持つ背景画像を持つクラスを持つ div があります。img は機能しますが、CSS の背景は機能しません。

<img src="../../Content/Themes/Default/images/DeleteIcon.jpg" />

#droptarget
{
    border: 1px solid #959595;
    height: 100px;
    width: 100px;
    content:'Drop here to Delete';
    background: url('../../Content/Themes/Default/images/DeleteIcon.jpg') no-repeat 140px 102px;
}
4

3 に答える 3

1

x 座標と y 座標のオフセットを取り除きます。それをdivから押し出します。

 background: url('../../Content/Themes/Default/images/DeleteIcon.jpg') no-repeat;
于 2013-08-03T07:59:36.137 に答える
1

0 0バックグラウンド位置として使用:
jsFiddle:こちら

于 2013-08-03T08:00:56.620 に答える
0

background-image次のbackground-repeatように使用することもできます。

#droptarget {
    border: 1px solid #959595;
    height: 100px;
    width: 100px;
    content:'Drop here to Delete';
    background-image: url('../../Content/Themes/Default/images/DeleteIcon.jpg');
    background-repeat: no-repeat;
}

background-positionまた、他の要素から継承している場合は、次を追加できます。

#droptarget {
    border: 1px solid #959595;
    height: 100px;
    width: 100px;
    content:'Drop here to Delete';
    background-image: url('../../Content/Themes/Default/images/DeleteIcon.jpg');
    background-repeat: no-repeat;
    background-position: 0 0;
}
于 2013-08-03T08:07:39.710 に答える