Web应用课 CSS实战项目个人名片设计(StackOverflow个人名片实现)
目录
StackOverflow网址:stack overflow
效果图:
实现步骤:
1.画出基本框架
2.写出基本实现框架
3.按照逻辑编写html文件
用到的标签有 <link>
、 <div>
、 <span>
、<img>
、 <a>
想了解的可参考我写的html小结:
代码见最终代码展示
4.按结构图编写css文件:
使用 shift + ctrl + c
, 可以看见名片元素标签的各项属性
根据各项属性设置结构中的标签即可。
最终代码展示:
html代码如下:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="static/css/style.css">
</head>
<body>
<div class="user-card">
<div class="user-card-head">
asked Feb 9, 2019 at 18:18
</div>
<div class="user-card-body">
<div class="user-card-body-photo">
<a href="https://www.acwing.com/user/myspace/index/273995/" target="_blank">
<img src="static/images/touxiang.webp" alt="哆啦B梦">
</a>
</div>
<div class="user-card-body-info">
<div class="user-card-body-info-username">
<a href="https://www.acwing.com/user/myspace/index/273995/" target="_blank">Pigwantofly</a>
</div>
<div class="user-card-body-info-reputation">
<span style="color: #6A737C; font-weight: bold;">1,025</span>
<div class="user-card-body-info-reputation-item" style="background-color: #FFCC01;"></div>
3
<div class="user-card-body-info-reputation-item" style="background-color: #b4b8bc;"></div>
14
<div class="user-card-body-info-reputation-item" style="background-color: #d1a684;"></div>
25
</div>
</div>
</div>
</div>
</body>
</html>
css代码如下:
.user-card-body-photo img {
width: 32px;
height: 32px;
border-radius: 3px;
}
.user-card {
width: 200px;
height: 67.69px;
background-color: #D9EAF7;
margin: 100px auto;
box-sizing: border-box;
padding: 5px 6px 7px 7px;
border-radius: 5px;
border-style: solid;
border-color: aqua;
}
.user-card-head {
font-size: 12px;
color: #6A737C;
margin: 1px 0px 4px 0px;
box-sizing: border-box;
}
.user-card-body-photo {
float: left;
}
.user-card-body-info {
float: left;
margin-left: 8px;
}
.user-card-body-info-username {
height: 14px;
line-height: 14px;
margin-bottom: 4px;
}
.user-card-body-info-username > a {
font-size: 13px;
color: #0074CC;
text-decoration: none;
}
.user-card-body-info-reputation {
font-size: 12px;
color: #838C95;
height: 14px;
line-height: 14px;
}
.user-card-body-info-reputation-item {
width: 6px;
height: 6px;
display: inline-block;
border-radius: 50%;
margin: 0px 3px 0px 2px;
position: relative;
top: -2px;
}