参考链接:https://www.runoob.com/try/try-cdnjs.php?filename=trycss_website_layout_blog
我是参考上述链接,稍微做些修改,然后如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>个人主页(runoob.com)</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family: Arial;
padding: 10px;
background: #f1f1f1;
}
/* 头部标题 */
.header {
padding: 30px;
text-align: center;
background: white;
}
.header h1 {
font-size: 50px;
}
/* 导航条 */
.topnav {
overflow: hidden;
background-color: #333;
}
/* 导航条链接 */
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* 链接颜色修改 */
.topnav a:hover {
background-color: rgb(16, 107, 243);
color: black;
}
/* 创建两列 */
/* Left column */
.leftcolumn {
float: left;
width: 75%;
}
/* 右侧栏 */
.rightcolumn {
float: left;
width: 25%;
background-color: #f1f1f1;
padding-left: 20px;
}
/* 图像部分 */
.fakeimg {
background-color: #aaa;
width: 100%;
padding: 20px;
}
/* 文章卡片效果 */
.card {
background-color: white;
padding: 20px;
margin-top: 20px;
}
/* 列后面清除浮动 */
.row:after {
content: "";
display: table;
clear: both;
}
/* 底部 */
.footer {
padding: 20px;
text-align: center;
background: rgb(240, 236, 19);
margin-top: 20px;
}
/* 响应式布局 - 屏幕尺寸小于 800px 时,两列布局改为上下布局 */
@media screen and (max-width: 800px) {
.leftcolumn, .rightcolumn {
width: 100%;
padding: 0;
}
}
/* 响应式布局 -屏幕尺寸小于 400px 时,导航等布局改为上下布局 */
@media screen and (max-width: 400px) {
.topnav a {
float: none;
width: 100%;
}
}
</style>
</head>
<body>
<div class="header">
<h1>欢迎来到个人主页</h1>
<p>初版网页效果的雏形</p>
</div>
<div class="topnav">
<a href="#">点击链接1</a>
<a href="#">关注链接2</a>
<a href="#">点开链接3</a>
<a href="#" style="float:right">右侧链接</a>
</div>
<div class="row">
<div class="leftcolumn">
<div class="card">
<h2>关注本文章的标题</h2>
<h5>2020 年 12 月 14日</h5>
<div class="fakeimg" style="height:200px;">图片1</div>
<p>一些文本...</p>
<p>来介绍一些基本的信息,比如姓名、年龄、身高、体重!</p>
</div>
<div class="card">
<h2>文章标题</h2>
<h5>2020 年 12 月 14日</h5>
<div class="fakeimg" style="height:200px;">图片2</div>
<p>一些文本...</p>
<p>来写点个人的兴趣、爱好、关于基本的一些想要做的事情等!</p>
</div>
</div>
<div class="rightcolumn">
<div class="card">
<h2>关于我</h2>
<div class="fakeimg" style="height:100px;">图片3</div>
<p>关于我的一些信息..</p>
</div>
<div class="card">
<h3>热门文章</h3>
<div class="fakeimg"><p>图片4</p>
</div>
<div class="fakeimg"><p>图片5</p></div>
<div class="fakeimg"><p>图片6</p></div>
</div>
<div class="card">
<h3>关注我</h3>
<p>参考一些相关的文本内容...</p>
</div>
</div>
</div>
<div class="footer">
<h2>关注底部需要关联的区域</h2>
</div>
</body>
</html>
图片如下: