回答:
あなたはこれを意味しますか?
<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>
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>
どこ:
background CSSプロパティは、その構文のすべてのbackground-xxxプロパティの接続です。
background: background-color background-image background-repeat background-attachment background-position ;
ソース: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>
次のIDのimg src属性を追加するだけです。
<body>
<img id="backgroundimage" src="bgimage.jpg" border="0" alt="">
</body>
そしてあなたのCSSファイル(ストレッチ背景)で:
#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>
そしてあなたのCSSファイルで:
.foo {
background-image: url("images/foo.png");
}
<div id="imgg">Example to have Background Image</div>
以下のコンテンツをStyleタグに追加する必要があります:
.imgg(
background-image: url('C:\Users\ajai\Desktop\10.jpg');
)
ほとんどの場合、方法は全身を設定するのと同じです
.divi{
background-image: url('path');
}
</style>
<div class="divi"></div>