Réponses:
Tu veux dire ça?
<style type="text/css">
.bgimg {
background-image: url('../images/divbg.png');
}
</style>
...
<div class="bgimg">
div with background
</div>
Vous pouvez le faire en utilisant les backgroundpropriétés de CSS . Il y a plusieurs façons de le faire:
HTML:
<div id="div-with-bg"></div>
CSS :
#div-with-bg
{
background: color url('path') others;
}
HTML:
<div class="div-with-bg"></div>
CSS :
.div-with-bg
{
background: color url('path') others;
}
HTML:
<div style="background: color url('path')"></div>
Où :
background La propriété CSS est une connexion de toutes les propriétés background-xxx dans cette syntaxe:
background : background-color background-image background-repeat background-attachment background-position ;
Source: w3schools
Utilisez ce style pour obtenir une image d'arrière-plan centrée sans répétition.
.bgImgCenter{
background-image: url('imagePath');
background-repeat: no-repeat;
background-position: center;
position: relative;
}
En HTML, définissez ce style pour votre div:
<div class="bgImgCenter"></div>
Utilisez comme ..
<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>
Vous pouvez simplement ajouter un attribut img src avec id:
<body>
<img id="backgroundimage" src="bgimage.jpg" border="0" alt="">
</body>
et dans votre fichier CSS (arrière-plan extensible):
#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>
et dans votre fichier CSS:
.foo {
background-image: url("images/foo.png");
}
<div id="imgg">Example to have Background Image</div>
Nous devons ajouter le contenu ci-dessous dans la balise Style:
.imgg(
background-image: url('C:\Users\ajai\Desktop\10.jpg');
)
Pour la plupart, la méthode est la même que le réglage du corps entier
.divi{
background-image: url('path');
}
</style>
<div class="divi"></div>