2016-11-07 4 views
0

透明な背景イメージがあり、その背景に灰色を追加したいのですが、それを行いましたが、ページの幅を広げることはできません(つまり、サイズを変更できませんバックグラウンドサイズの属性を使用した後でも)。イメージに追加される背景のサイズを大きくすることができないのはなぜですか?

img{ 
 
    height:40px; 
 
    width:40px; 
 
    background-color:rgb(0, 0, 0); 
 
    background-size:100px 100px; 
 
}
<img src="https://www.google.co.in/search?espv=2&biw=1366&bih=662&tbm=isch&sa=1&q=html+logo+transparent+background&oq=html+logo+tra&gs_l=img.1.1.0j0i30k1.3420.4038.0.5941.4.4.0.0.0.0.302.302.3-1.1.0....0...1c.1.64.img..3.1.301.xRQ23nL94iw#imgrc=FkYJhNmbMb325M%3A" align="center">

+0

に背景画像を使用して変更'40x X 40px' – Dekel

答えて

0

あなたの要素の幅/高さのみであるため、高さと幅

img{ 
     height:100%; 
     width:100%; 
     } 
+0

それはイメージのものです、どうすればいいですか??? – KSJ10

+0

はいこれはimgのスタイルで、40%から100% –

1

は、親のdiv

<style> 
     .parent { 
      width: 100%; 
      background-image:url('yourimage.jpg'); 
      background-position: center center; 
      background-color: grey; 
     } 
    </style> 

    <div class="parent"> 

    </div> 
関連する問題