制作“用户中心”——盒子模型

1、打开VSCode,在自己的文件夹中新建网页文件,文件名06user.html

2、具体步骤

2.1 将title标签内容改为“用户中心”

<title>用户中心</title>

2.2 在 < body > 内添加 < div > 的盒子

<body>
    <div class="box"> 
    </div>
</body>

2.3 在 < div > 中添加两个盒子 < div >,分别放置图像标签和4个段落标签

<body>
    <div> 
        <div>
        </div>
        <div>
        </div>
    </div>
</body>

2.4 设置 < div > 的class值,在css文件夹中新建文件06user.css

<body>
    <div class="box"> 
        <div>
            <img src="06user.jpg" alt="用户头像">
        </div>
        <div class="info">
            <p>用户姓名:</p>
            <p>学习进度:</p>
            <p>兴趣爱好:</p>
            <p>参与的群:</p>
        </div>
    </div>
</body>
    </div>

2.5 在06user.html的 < head > 标签中引入css文件

<link rel="stylesheet" href="06user.css">

3、代码

  • HTML代码:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户中心</title>
    <link rel="stylesheet" href="06user.css">
</head>
<body>
    <div class="box"> 
        <div>
            <img src="06user.jpg" alt="用户头像">
        </div>
        <div class="info">
            <p>用户姓名:</p>
            <p>学习进度:</p>
            <p>兴趣爱好:</p>
            <p>参与的群:</p>
        </div>
    </div>
</body>

在这里插入图片描述

  • CSS代码:
*{
    padding: 0;
    margin: 0;
    border: 0;
}
.box{
    font-family: "微软雅黑";
    font-size: 16px;
    width: 150px;
    height: 274px;
    margin: 50px auto;
}
.info p{
    width: 138px;
    height: 33px;
    line-height: 33px;
    border: 1px solid #2e3138;
    margin-top: 2px;
    padding-left: 10px;
}
.box img{
    display: block;
}

在这里插入图片描述

4、效果图

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_45756724/article/details/108644431
今日推荐