|

楼主 |
发表于 2018-11-25 10:38:12
|
显示全部楼层
图片和html文件在同一文件夹,完整代码如下:
<!doctype.html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="keywords" content="朱自清,背影,HTML学习">
<meta name="description" content="朱自清的《背影》">
<meta name="author" content="白小弈">
<style>
body{
background-image: url("背景.jpg");
}
h1{
text-align: center;
color: black;
}
h2{
margin-left: 60%;
color: black;
}
p{
text-indent: 32px;
font-size: 16px;
line-height: 32px;
color: black;
}
img{
position: absolute;
left: 40%;
margin-left: -181px;
}
</style>
<style media="print">
h1{
color: black;
}
h2{
color: black;
}
p{
color: black;
}
</style>
<style media="screen and (min-width:512px) and (max-width:1024px)">
body{
background-image: url("背景2.jpg");
}
</style>
</head>
<body>
<h1>背影</h1>
<h2>朱自清</h2>
<p>
我与父亲不相见已二年余了,我最不能忘记的是他的背影 。</p>
</p>
<img src="timg.jpg" alt="背影的图片找不到了!">
</body>
</html> |
|