如何使用 CSS 创建网站的关于/关于我们页面?
网站的关于页面包含团队详细信息,包括姓名、职位、联系方式、联系按钮等。首先,为关于页面设置一个容器。在容器内,为列、卡片、个人资料等设置子容器。个人资料包括姓名、职位和一个联系按钮。让我们看看如何使用 HTML 和 CSS 创建网站的关于我们页面。
创建一个 div 容器
容器用于关于页面的团队详细信息。容器中的团队卡片包含其他子容器 -
<div class="teamColumn">
<div class="teamCard">
<img
src="https://images.pexels.com/photos/839011/pexels-photo-839011.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"
/>
<div class="personContainer">
<h3>Jane Doe</h3>
<p class="Designation">CTO</p>
<p><button class="contact">Contact</button></p>
</div>
</div>
</div>
为个人资料创建子容器
在父 div 内,我们将为人员详细信息创建一个子 div -
<div class="personContainer"> <h3>Jane Doe</h3> <p class="Designation">CTO</p> <p><button class="contact">Contact</button></p> </div>
团队成员的列
我们为团队三名成员的详细信息创建了三列 -
.teamColumn {
display: inline-block;
width: 300px;
height: 400px;
margin-bottom: 16px;
padding: 0 8px;
}
团队卡片
团队卡片的样式如下 -
.teamCard {
background-color: rgb(162, 162, 255);
text-align: center;
font-size: 20px;
}
带有人员容器的个人资料详细信息
在团队卡片 div 内,我们有人员容器。团队成员的职位也在这里设置样式 -
.personContainer {
padding: 0 16px;
}
.Designation {
color: rgb(15, 0, 100);
font-weight: bolder;
font-size: 20px;
}
联系按钮
这里设置了联系团队成员的按钮样式。cursor 属性设置为 pointer,使按钮看起来可点击 -
.contact {
border: none;
outline: 0;
display: inline-block;
padding: 12px;
color: white;
font-weight: bolder;
background-color: rgb(78, 0, 102);
text-align: center;
cursor: pointer;
width: 100%;
}
示例
要创建关于页面,代码如下 -
<!DOCTYPE html>
<html>
<head>
<style>
html {
box-sizing: border-box;
}
body {
font-family: monospace, serif, sans-serif;
margin: 0px;
padding: 0px;
}
h1 {
text-align: center;
background-color: rgb(108, 18, 131);
color: white;
padding-top: 40px;
padding-bottom: 40px;
margin-top: 0px;
}
.teamContainer {
margin-left: 10%;
}
img {
width: 100%;
height: 200px;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
.teamColumn {
display: inline-block;
width: 300px;
height: 400px;
margin-bottom: 16px;
padding: 0 8px;
}
@media screen and (max-width: 650px) {
.teamColumn {
display: block;
}
}
.teamCard {
background-color: rgb(162, 162, 255);
text-align: center;
font-size: 20px;
}
.personContainer {
padding: 0 16px;
}
.personContainer::after,
.teamContainer::after {
content: "";
clear: both;
display: table;
}
.Designation {
color: rgb(15, 0, 100);
font-weight: bolder;
font-size: 20px;
}
.contact {
border: none;
outline: 0;
display: inline-block;
padding: 12px;
color: white;
font-weight: bolder;
background-color: rgb(78, 0, 102);
text-align: center;
cursor: pointer;
width: 100%;
}
.contact:hover {
background-color: #555;
}
</style>
</head>
<body>
<h1>About Us</h1>
<div class="teamContainer">
<div class="teamColumn">
<div class="teamCard">
<img src="https://images.pexels.com/photos/839011/pexels-photo-839011.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" />
<div class="personContainer">
<h3>Jane Doe</h3>
<p class="Designation">CTO</p>
<p><button class="contact">Contact</button></p>
</div>
</div>
</div>
<div class="teamColumn">
<div class="teamCard">
<img src="https://images.pexels.com/photos/614810/pexels-photo-614810.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" />
<div class="personContainer">
<h3>Mike Ross</h3>
<p class="Designation">Front End Developer</p>
<p><button class="contact">Contact</button></p>
</div>
</div>
</div>
<div class="teamColumn">
<div class="teamCard">
<img src="https://images.pexels.com/photos/736716/pexels-photo-736716.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" />
<div class="personContainer">
<h3>John Doe</h3>
<p class="Designation">FullStack Developer</p>
<p><button class="contact">Contact</button></p>
</div>
</div>
</div>
</div>
</body>
</html>
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP