如何在html中添加背景图像?
您可以使用background css属性设置html元素的背景图像 .css如何在html中添加背景图像?,html,background,Html,Background,您可以使用background css属性设置html元素的背景图像 .css <div id="header" style="background-image:"URL of file?"> <h1 style="margin-bottom:15;text-align:center;"> <font face="Lucida Calligraphy"> <u>Text to be displaye
<div id="header" style="background-image:"URL of file?">
<h1 style="margin-bottom:15;text-align:center;">
<font face="Lucida Calligraphy">
<u>Text to be displayed</u>
</font>
</h1>
</div>
然后实施
.html
/*[Option A]*/
html {
background: url(images/bg.jpg);
}
/*Or if you have a, or want to use a class*/
/*[Option B]*/
.someClass {
background: url(images/bg.jpg);
}
这两个选项几乎可以应用于任何图元
更多关于
您应该使用CSS进行样式设置。您使用的
标记已弃用。您还应该使用HTML5标题
标记
将HTML仅作为标记:
<!--[If you use Option A]-->
<html></html>
<!--[If you use Option B]-->
<div class="someClass"></div>
<header>
<h1>Text to be displayed</h1>
</header>
header{
background-image:url('url of file');
}
h1{
margin-bottom:15px;
text-align:center;
font-family:'Lucida Calligraphy', sans-serif;
text-decoration:underline;
}