css 作业 2
    		       		warning:
    		            这篇文章距离上次修改已过434天,其中的内容可能已经有所变动。
    		        
        		                
                CSS作业2的具体要求没有给出,但我们可以提供一个简单的CSS任务示例,比如创建一个带有背景图片的简单网页。
HTML文件(index.html):
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS 作业示例</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="background">
        <h1>欢迎来到我的网页</h1>
    </div>
</body>
</html>CSS文件(style.css):
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
}
 
.background {
    background-image: url('background.jpg'); /* 替换为你的图片路径 */
    background-size: cover;
    background-position: center;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}
 
.background h1 {
    color: white;
    font-size: 48px;
    font-weight: bold;
    margin: 0;
    padding: 20px;
}确保你有一个名为background.jpg的图片文件,并放在与CSS文件相同的目录下。这个简单的示例展示了如何给一个div元素设置背景图片,并在其中居中显示一个h1标题。
评论已关闭