HTML+CSS 基础布局(案列二)
主题《新世界》html+css 静态布局(二)
刚开始学习了一个星期html和css之后,老师布置了这样一个作业,就是一张图,然后这样了
新世界 | 代码 | 说明 |
html 部分 |
<!DOCTYPE html> //添加下拉选择表单 <form> //添加了提示输入placeholder |
图片材料就不上存了 |
css 部分 |
body{ background-color: #44565C; color:#767777; font-size: 12px; font-family: "Microsoft YaHei"; margin: 0 auto; } * { margin: 0; padding: 0; } .tutu{ width: 800px; height: 2750px; margin:0 auto; background-color: #fff; padding: 0; } header{ position: relative; padding-top: 10px; } header img{ width: 20px; height: 20px; float: left; padding-left: 30px; } header p{ float: left; padding-left: 7px; } header ul{ list-style: none; float: right; padding-right:20px; } header ul li{ float: left; } header ul li a{ text-decoration: none; //去掉链接标签的下滑线 float: left; color: gray; padding-right: 20px; } header ul li a:hover{ //当鼠标触碰是字体颜色为红色 color: red; } header ul li img{ width: 13px; height: 13px; } .header{ margin-top: 30px; height: 400px; background-color: yellow; background-image: url(images/life.gif); color: white; } .header .life-1{ font-size: 40px; padding-top: 100px; padding-left: 50px; } .header .life-2{ font-size: 13px; padding-top: 10px; padding-left: 50px; } .header .header-action{ margin-top: 40px; margin-left: 50px; width: 180px; height: 40px; background-color: red; } .header .header-action a{ text-decoration: none; color: white; font-size: 20px; line-height: 40px; padding: 20px 0px 0px 50px; } .content-1{ height:150px; padding-top:20px; /*background-color: green;*/ } .content-1 .content-1-1{ width: 100px; text-align: center; padding-left:50px; float: left; } .content-1 .content-1-2{ width: 100px; text-align: center; padding-left:50px; float: left; } .content-1 .content-1-3{ width: 100px; text-align: center; padding-left:50px; float: left; } .content-1 .content-1-4{ width: 100px; text-align: center; padding-left:50px; float: left; } .content-1 .vertical{ float: left; width: 1px; height: 50px; margin-top: 50px; background-color: green; margin-left: 50px; } .content-2{ height: 180px; background-color: #F0F8FF; } .content-2 img{ position: relative; padding-top: 30px; width: 50px; height: 50px; padding-left:365px; } .content-2 p{ font-size:30px; padding-left: 160px; } .content-3{ height: 200px; color: white; text-align: center; background-image: url(images/search-bg.jpg); } .content-3 .content-3-p1{ padding-top: 30px; font-size: 15px; } .horizontal{ width: 20px; height: 2px; margin-top: 5px; margin-left:390px; background-color: white; } .content-3 .content-3-p2{ font-size: 10px; margin-top: 8px; } form{ float: left; margin: 40px; } form select{ width: 130px; height: 25px; margin-left: 40px; } .content-3 .search{ width: 140px; height: 25px; float: left; margin-top: 40px; background-color: red; } .content-3 .search a{ text-decoration: none; color: white; line-height: 25px; } .content-4{ height: 320px; background-color: #F0FFFF; } .content-4 img{ width: 130px; height: 200px; float: left; } .content-4 .img{ padding: 35px; float: left; text-align: center; } .content-4 strong{ font-size: 16px; } .content-5{ height: 350px; /*background-color: gray;*/ } .content-5 .back-img{ width: 550px; height: 350px; float: left; color: white; text-align: center; background-image: url(images/slide.jpg); } .content-5 .back-img .ct-5-p1{ font-size: 22px; padding-top: 70px; } .content-5 .back-img .ct-5-p2{ font-size: 90px; } .content-5 .back-img .ct-5-p3{ font-size: 12px; color: #FFFAFA; } .content-5 .back-img .ct-5-p4{ font-size: 12px; color: #FFFAFA; } .content-5 .content-5-r{ text-align: center; } .content-5 .content-5-r .ct-5-p5{ padding-top: 80px; font-size: 15px; color: black; } span{ color: red; } .content-5 .content-5-r .ct-5-p{ width: 250px; height: 180px; float: left; } .content-5 .content-5-r .ct-5-p6{ color: #C0C0C0; font-size: 8px; line-height: 25px; padding: 20px; } .content-5 .content-5-r .more{ width: 80px; height: 20px; float: left; margin-left: 80px; } .content-5 .content-5-r .more a{ text-decoration: none; color: red; } .content-5 .content-5-r ul{ list-style: none; position: relative; float: left; margin-left: 71px; } .content-5 .content-5-r ul li{ width: 8px; height: 8px; border: 1px solid black; /*添加边框*/ border-radius: 50%; /*构造圆*/ /*background-color: red;*/ float: left; margin: 5px; } .content-5 .content-5-r ul li:hover{ cursor: pointer; /*当鼠标触碰时,光标样式为小手*/ background-color: red; } .content-6{ height: 350px; background-color: green; } .content-6 .ct-6-1{ width: 275px; height: 350px; float: left; color: white; text-align: center; background-color: #F08080; } .content-6 .ct-6-1 .ct-6-p1{ padding-top: 100px; font-size: 15px; } .content-6 .ct-6-1 .hr1{ width: 15px; margin-top: 15px; margin-left: 125px; } .content-6 .ct-6-1 .more-1{ width: 110px; height: 25px; margin-left: 80px; margin-top: 15px; padding-top: 5px; } .content-6 .ct-6-1 .more-1 a{ text-decoration: none; color: white; } .content-6 .ct-6-2{ width: 275px; height: 350px; float: left; text-align: center; background-color: #FFF5EE; } .content-6 .ct-6-2 .ct-6-p3{ padding-top: 100px; font-size: 15px; } .content-6 .ct-6-2 .hr2{ width: 15px; margin-top: 15px; margin-left: 125px; } .content-6 .ct-6-2 .more-2{ width: 110px; height: 25px; margin-left: 80px; margin-top: 15px; padding-top: 5px; } .content-6 .ct-6-2 .more-2 a{ text-decoration: none; color: red; } .content-7 { height: 180px; text-align: center; } .content-7 .ct-7-p1{ font-size: 18px; padding-top: 60px; } .content-7 .ct-7-hr{ width: 20px; margin: 5px 0px 8px 390px; } .content-8{ height: 300px; /*background-color: #DCDCDC;*/ } .content-8 .ct-8-l{ width: 250px; height: 300px; float: left; padding-left: 50px; /*background-color: green;*/ } .content-8 .ct-8-l .title{ color: black; font-size: 14px; } .content-8 .ct-8-l .ct-8-more{ margin-left: 200px; } .content-8 .ct-8-l a{ text-decoration: none; color: red; } .ct-8-r{ width: 500px; height: 300px; float: right; /*background-color: #F0E68C;*/ } .ct-8-r p{ float: left; } .ct-8-r form{ margin: 0; padding:0; } .ct-8-r .input-in4{ position: absolute; width: 135px; height: 25px; font-size: 15px; margin-top: 2px; } .ct-8-r .line-h{ width: 200px; height: 30px; line-height: 30px; background-color: #DCDCDC; } .ct-8-r .name{ float: left; margin-left:20px; } .ct-8-r .name p{ padding-left: 18px; } .ct-8-r .age{ float: left; margin-left:20px; } .ct-8-r .age p{ padding-left: 18px; } .ct-8-r .telephone{ float: left; margin-top: 15px; margin-left:20px; } .ct-8-r .address{ float: left; margin-top: 15px; margin-left:20px; } .ct-8-r .dream{ width: 420px; height: 140px; float: left; margin-top: 15px; margin-left: 20px; background-color: #DCDCDC; } .ct-8-r .dream textarea{ resize: none; width: 418px; height: 111px; } .ct-8-r .dream p{ padding:5px 0 5px 0px; } .ct-8-r .submit{ width: 420px; height: 25px; float: left; margin-top: 15px; margin-left: 20px; text-align: center; line-height: 25px; background-color: #DCDCDC; } .ct-8-r .submit a{ text-decoration: none; color: red; } .footer{ height: 250px; color: white; text-align: center; background-color: #33353F; } .footer form{ margin:0; padding:0; } .footer .me{ font-size: 18px; padding-top: 50px; } .footer input{ width: 250px; height: 20px; float: left; margin-top: 20px; margin-left: 250px; } .footer .submit{ width: 50px; height: 24px; line-height: 24px; float: left; margin-top: 20px; background-color: #5F9EA0; } .footer .submit a{ text-decoration: none; color: white; } .footer .icon{ width: 800px; float: left; height: 60px; } .footer .icon img{ width:20px; height:20px; margin-top: 10px; padding: 5px; } .footer .icon img{ cursor: pointer; } .footer .end{ float: left; width: 800px; height: 40px; line-height: 40px; background-color: #2f3038; } .footer .end p{ float: left; font-size: 10px; padding-left: 50px; } .footer .end span{ float: right; } .footer .end a{ text-decoration: none; padding-right: 30px; color: white; font-size: 8px; } |
|
思路 | 从上往下构思好层级关系,划分好盒子关系,然后一个个地布局下来 |
陌陌说:这里有一些比较常用重要的知识点:比如构造竖线,横线,选择的圆点,输入框的提示输入等