第一次做的网页
css部分
body{/*可以在这里对网页整体背景进行调整*/
/*background-image: url(../image/background.jpg);
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
background-color: #cccccc;*/
margin: 0;
}
*{
box-sizing: border-box;
}
/*头部样式,对顶部图片背景,文字可进行编辑替换*/
.header{
background-color: #f1f1f1;
padding: 20px;
text-align: left;
background-image: url(../image/background.jpg);/*可对顶部背景图进行替换*/
}
.header h1{/*对顶部logo样式的定义*/
padding: 1px;
margin-top: 1px;
margin-bottom: 1px;
}
/*对导航条样式的定义*/
.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: #ddd;
color: black;
}
/*创建两列*/
/*左侧栏*/
.leftcolumn{
float: left;
width: 75%;
}
/*右侧栏*/
.rightcolumn{
float: left;
width: 25%;
background-color: #f1f1f1;
padding-left: 20px;
}
/*左右栏中的## 标题图像部分*/
.fakeimg{
background-color: white;
width: 100%;
padding: 0;
}
/*文章卡片效果*/
.card{
background-color: white;
padding: 20px;
margin-top: 20px;
}
/*列后面清除浮动*/
.row:after{
content: "";
display: table;
clear: both;
}
/*网页底部*/
.footer{
padding: 20px;
text-align: center;
background:#ddd;
margin-top: 0;
}
/*响应式布局 屏幕尺寸小于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%;
}
}
HTML部分
首页HTML部分
<!DOCTYPE html>
<html>
<head>
<title>首页名称</title>
<link rel="stylesheet" type="text/css" href="../css/first.css">/*链接css*/
</head>
<body>
<div class="header">/*头部内容*/
<h1><img src="logo图片链接"></h1>
</div>
<div class="topnav">
<a href="#">链接</a>
<a href="#">链接</a>
<a href="#" style="float: right">处在导航栏右侧的链接</a>
</div>
<div class="row">
<div class="leftcolumn">/*左侧栏目内容*/
<div class="card">
<h2>文章名字</h2>
<div class="fakeimg" style="height: 200px;"><a href="图片所指向的跳转位置的链接"><img src="要插入的图片的路径"></a></div>
<p>文字注释</p>
</div>
</div>
<div class="rightcolumn">/*右侧栏目内容*/
<div class="card">
<h2>关于我</h2>
<div class="fakeimg" style="height: 100px;"><a href="文字跳转链接"><img src="图片位置"></a></div>
</div>
<div class="card">
<h3>我的视频</h3>
<div class="fakeimg"><a href="链接跳转"><img src="图片路径"></a></div><p>文字注释</p>
</div>
</div>
</div>
<div class="footer">
/*这里可以添加网页尾部的相关内容*/
</div>
</body>
</html>
第一次所做,如有错误,欢迎讨论指正