जवाबों:
आपका मतलब इससे है?
<style type="text/css">
.bgimg {
background-image: url('../images/divbg.png');
}
</style>
...
<div class="bgimg">
div with background
</div>
आप ऐसा कर सकते हैं कि CSS के backgroundप्रॉपर्टीज़ का उपयोग किया जाए। इसे करने के कुछ तरीके हैं:
HTML:
<div id="div-with-bg"></div>
सीएसएस :
#div-with-bg
{
background: color url('path') others;
}
HTML:
<div class="div-with-bg"></div>
सीएसएस :
.div-with-bg
{
background: color url('path') others;
}
HTML:
<div style="background: color url('path')"></div>
कहां :
background CSS प्रॉपर्टी उस सिंटैक्स में सभी पृष्ठभूमि-xxx प्रॉपर्टीज का एक कनेक्शन है:
पृष्ठभूमि : पृष्ठभूमि-रंग पृष्ठभूमि-छवि पृष्ठभूमि-दोहराव पृष्ठभूमि-अनुलग्नक पृष्ठभूमि-स्थिति ;
स्रोत: w3schools
का उपयोग करें ..
<div style="background-image: url(../images/test-background.gif); height: 200px; width: 400px; border: 1px solid black;">Example of a DIV element with a background image:</div>
<div style="background-image: url(../images/test-background.gif); height: 200px; width: 400px; border: 1px solid black;"> </div>
आप बस आईडी के साथ एक img src विशेषता जोड़ सकते हैं:
<body>
<img id="backgroundimage" src="bgimage.jpg" border="0" alt="">
</body>
और आपकी सीएसएस फ़ाइल (स्ट्रेच बैकग्राउंड) में:
#backgroundimage
{
height: auto;
left: 0;
margin: 0;
min-height: 100%;
min-width: 674px;
padding: 0;
position: fixed;
top: 0;
width: 100%;
z-index: -1;
}
<div class="foo">Foo Bar</div>
और अपनी सीएसएस फ़ाइल में:
.foo {
background-image: url("images/foo.png");
}
<div id="imgg">Example to have Background Image</div>
हमें स्टाइल टैग में नीचे दी गई सामग्री को जोड़ने की आवश्यकता है:
.imgg(
background-image: url('C:\Users\ajai\Desktop\10.jpg');
)
अधिकांश भाग के लिए, विधि पूरे शरीर को सेट करने के समान है
.divi{
background-image: url('path');
}
</style>
<div class="divi"></div>