刚开始学习前端,在仅使用HTML和CSS的情况下,也可以写出一个页面,使用HTML对页面的内容进行架构,再此基础上使用CSS对内容进行美化。其中涉及了许多HTML和CSS的知识点,定位 浮动 链接 等,修改字体、图片大小、背景颜色、鼠标样式、鼠标与页面的交互、行内元素与块元素等。
学习来源:黑马程序员
**运行环境:**编码——Sublime 运行——chrome浏览器
HTML代码:
狮子大百科
CSS代码
*{
margin:0;
padding:0;
}
body{
background-color:#fafafa;
}
li{
list-style:none;
}
.header {
height:100px;
background-color:#fff;
}
.inner {
width: 1200px;
height: 100px;
background-color:white;
margin:0 auto;
line-height:100px;
}
.logo {
float:left;
}
.nav{
float:right;
}
.nav li{
float:left;
margin:0 20px;
font-family:"微软雅黑";
}
.nav li a{
color:#333;
text-decoration:none;
}
.nav li a:hover{
color:red;
}
.banner{
height:620px;
background:url(../images/bg1.jpg) no-repeat top center;
}
.service{
width:1055px;
height:1000px;
margin:75px auto 0;
}
.case{
width:1055px;
height:350px;
margin:75px auto 0;
}
.service-hd{
border-top:1px solid #ccc;
margin:0 25px;
}
.service-hd h3{
width: 167px;
height: 46px;
margin:0 auto;
margin-top:-20px;
}
.service-hd p{
font-size:25px;
color:#666;
line-height:35px;
text-align:center;
width:830px;
margin:15px auto 0;
}
.service-bd{
margin-top:40px;
background-color:blue;
}
.service-bd li {
width:300px;
height:800px;
border-color:blue;
background-color:white;
float:left;
border:1px solid #e7e8e9;
}
.yingxiao{
margin:0 45px;
}
.service-bd img{
margin:40px 25px ;
}
.service-bd h3{
text-align:center;
font-size:18px;
height:40px;
}
.service-bd p{
font-size:18px;
color:#666;
width: 235px;
margin:0 45px;
line-height:35px;
}
.clearffix;after{content:"";display:block;height:0;clear:both;visibility:hidden;
}
.clearfix{zoom:1;}
.service-bd a{
display:block;
width: 148px;
height:38px;
border:1px solid #ff9412;
margin:30px auto 0;
text-align:center;
line-height:38px;
font-size:12px;
text-decoration:none;
border-radius:5px;
cursor:pointer;
}
.service-bd a:hover{
color:#fff;
background-color:#ff9412;
}
.case-bd{
margin-top:60px;
position:relative;
}
.case-bd li{
width:325px;
height:210px;
float:left;
position:relative;
}
.mask{
width: 100%;
height:100%;
background:rgba(0, 0, 0, 0.3) url(../images/fdj.png) center no-repeat;
position:absolute;
top:0;
left:0;
display:none;
}
.case-bd li:hover .mask{
display:block;
cursor:pointer;
}
.case-bd-m{
margin:0 40px;
}
.media-bd{
width:1048px;
height:240px;
overflow:hidden;
}
.media-bd li{
width: 210px;
height: 80px;
float:left;
border-right:1px dashed #ccc;
border-bottom:1px dashed #ccc;
text-align:center;
padding-top:10px;
}
.media-bd ul{
width: 1060px;
}
.footer{
height: 165px;
background-color:#212425;
margin-top:100px;
overflow:hidden;
}
.subnav{
text-align:center;
margin-top:50px;
color:white;
font-size:14px;
}
.subnav a{
text-decoration:none;
color:#f0f1f1;
padding:0 5px;
font-size:16px;
}
.subnav a:hover{
color:skyblue;
text-decoration:underline;
}
.footer p{
color:#888888;
text-align:center;
margin-top:30px;
font-size:12px;
}
.text{
height:45px;
width:100%;
position:absolute;
left:0;
bottom:0;
text-align:center;
line-height:45px;
font-size:12px;
color:white;
background:rgba(0, 0, 0,.3)
}
文件放置
备注
CSS与HTML代码分别在两个文件内书写,按照页面的内容从上至下的顺序书写,页面内使用的图片素材,使用windows自带的画图3D调整图片素材的像素。














