老师您好,请检查作业,是否有可以优化的地方,感谢!
4-11 自由编程
本课程系列的习题页面,还有两个区域没有实现,一个是gallery区域,一个是页脚,现在让我们参考效果标注图来完成这两部分的布局吧。
css相关代码:
*{ margin: 0; padding: 0; } /* 去掉所有超级链接的下划线 */ a{ text-decoration: none; } header{ height: 80px; background-color: #07cbc9; } header .header-top{ width: 1200px; margin: 0 auto; text-align: center; overflow: hidden; } header .header-top .logo{ float: left; height: 48px; padding-top: 16px; color: white; } header .header-top nav{ float: right; } header .header-top nav ul li{ float: left; list-style: none; font-size: 16px; color: white; margin: 10px; padding-top: 20px; } .banner{ position: relative; width: 100%; height: 600px; top: 0; } .banner img{ width: 100%; height: 600px; } .banner .cover{ position: absolute; top: 0; width: 100%; height: 600px; background:rgba(0, 0, 0, 0.5) } .banner form{ position: absolute; top: 100px; left: 50%; margin-left: -252px; width: 504px; height: 350px; color: #808080; /* 给form标签添加text-align:center;属性,让按钮水平居中显示 */ text-align:center; } .banner form .form-box{ width: 504px; height: 40px; margin-bottom: 20px; /* 除表单元素的背景颜色 */ background: none; border: 1px solid #808080; } .banner form textarea{ width: 504px; height: 110px; /* 除表单元素的背景颜色 */ background: none; border: 1px solid #808080; } .banner form .submit-btn{ width: 200px; height: 40px; margin-top: 10px; text-align: center; /* 除表单元素的背景颜色 */ background: none; color: #808080; border: 1px solid #808080; } .about{ width: 1200px; margin: 0 auto; margin-top: 30px; } .about .about-top{ width: 1200px; } .about .about-top h2{ font-size: 32px; text-align: center; } .about .about-top .about-underline{ width: 60px; height: 3px; background-color: #07cbc9; margin: 10px auto; } .about .about-top .about-intro{ width: 440px; height: 60px; font-size: 14px; color: grey; text-align: center; margin: 0 auto; } .about .about-content{ position: relative; width: 1200px; height: 465px; overflow: hidden; } .about .about-content .about-us{ float: left; width: 341px; height: 362px; } .about .about-content .about-us h3{ float: left; font-size: 28px; margin-top: 20px; } .about .about-content .about-us .about-article{ position: absolute; float: left; top: 50%; margin-top: -103px; width: 300px; padding: 20px; font-size: 18px; border: 1px solid grey; background: rgba(255, 255, 255, 0.5); } .about .about-content .about-us .about-article .btn-explore{ width: 140px; height: 40px; background-color: black; text-align: center; line-height: 40px; margin-top: 25px; } .about .about-content .about-us .about-article .btn-explore a{ color: white; } .about .about-content .about-pic { float: left; margin-top: 30px; margin-left: -72px; width: 650px; height: 435px; } .about .about-content .faculty-stdnt-num{ float:right; right: 0; margin-top: 30px; width: 260px; height: 338px; } .about .about-content .faculty-stdnt-num .common{ float: right; width: 258px; padding-top: 40px; padding-bottom: 40px; margin-bottom: 30px; text-align: center; border: 1px solid #07cbc9; } .about .about-content .faculty-stdnt-num .common .r1{ font-size: 20px; font-weight: bold; } .about .about-content .faculty-stdnt-num .common .underline{ width: 45px; height: 3px; background-color: #07cbc9; margin: 10px auto; } .text-and-graphics{ width: 100%; height: 760px; margin-top: 20px; overflow: hidden; } .text-and-graphics .row1{ width: 100%; height: 380px; } .text-and-graphics .row2{ width: 100%; height: 380px; } .text-and-graphics .pic-common{ float: left; width: 25%; height: 380px; } .text-and-graphics .pic-common img{ width: 100%; height: 380px; } .text-and-graphics .text-common{ float: left; width: 25%; height: 380px; background-color: #07cbc9; } .text-and-graphics .text-common h3{ font-size: 24px; color: white; padding-top: 20px; margin-left: 20px; margin-bottom: 30px; } .text-and-graphics .text-common .r1{ font-size: 16px; color: white; margin-left: 20px; margin-bottom: 20px; } .text-and-graphics .text-common .r2{ font-size: 14px; color: gray; margin-left: 20px; margin-right: 20px; margin-bottom: 30px; } .text-and-graphics .text-common .btn-explore{ width: 138px; height: 40px; background-color: black; text-align: center; line-height: 40px; margin: auto; } .text-and-graphics .text-common .btn-explore a{ color: white; } .gallery{ width: 1200px; margin: 0 auto; margin-top: 30px; } .gallery .gallery-info{ width: 1200px; } .gallery .gallery-info h3{ font-size: 32px; text-align: center; } .gallery .gallery-info .about-underline{ width: 60px; height: 3px; background-color: #07cbc9; margin: 10px auto; overflow: hidden; } .gallery .gallery-info p{ width: 440px; height: 60px; font-size: 14px; color: grey; text-align: center; margin: 0 auto; } .gallery .gallery-content{ width: 1200px; height: 653px; margin-top: 5px; overflow: hidden; } .gallery .gallery-content dl{ float: left; margin: 15px 20px; width: 360px; height: 290px; } .gallery .gallery-content dl dt img{ display: block; float: left; width: 360px; height: 240px; } .gallery .gallery-content dl dd{ display: block; float: left; width: 340px; height: 50px; background-color: black; padding-left: 20px; line-height: 50px; } .gallery .gallery-content dl dd a{ color: white; } footer{ width: 100%; height: 80px; background-color: #07cbc9; text-align: center; line-height: 80px; }
html相关代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="css/css.css"> </head> <body> <!-- 页面头部 --> <header> <div class="header-top"> <!-- 网页的logo --> <div class="logo"> <h1>Career Builder</h1> </div> <!-- 网页的导航条 --> <nav> <ul> <li>HOME</li> <li>ABOUT</li> <li>GALLERY</li> <li>FACULTY</li> <li>EVENTS</li> <li>CONTACT</li> </ul> </nav> </div> </header> <!-- 网页的banner --> <div class="banner"> <img src="images/banner3.jpg"> <div class="cover"></div> <form action="save.php" method="post"> <p> <input class="form-box" type="text" placeholder="your Name"> </p> <p> <input class="form-box" type="text" placeholder="your Phone"> </p> <p> <input class="form-box" type="email" placeholder="your Email"> </p> <p> <textarea cols="50" rows="10" placeholder="Write Your Conment Here"></textarea> </p> <input class="submit-btn"type="submit" value="SEND MESSAGE"> </form> </div> <!-- about区域 --> <div class="about"> <div class="about-top"> <h2>ABOUT</h2> <div class="about-underline"></div> <div class="about-intro">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s</div> </div> <div class="about-content"> <div class="about-us"> <h3>A WORD<br/> ABOUT US </h3> <div class="about-article"> <p> Praesent dignissim viverra est,sed bibendum ligula congue non. Sed ac nisl et felis gravida commodo? Suspendisse eget ullamcorper ipsum. Suspendisse diam amet </p> <div class="btn-explore"> <a href="">EXPLORE</a> </div> </div> </div> <div class="about-pic"> <img src="images/bb3.jpg"> </div> <div class="faculty-stdnt-num"> <div class="student-num common"> <div class="r1">70000</div> <div class="underline"></div> <p>Students</p> </div> <div class="faculty-num common"> <div class="r1">600</div> <div class="underline"></div> <p>Faculty</p> </div> </div> </div> </div> <!-- 图文混排区域 --> <div class="text-and-graphics"> <!-- 第一排图文混排 --> <div class="row1"> <div class="pic01 pic-common"> <img src="images/b1.jpg" alt=""> </div> <div class="text01 text-common"> <h3>Library</h3> <p class="r1">Lorem Ipsum is simply dummy text of the printing and typesetting industry</p> <p class="r2">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p> <div class="btn-explore"> <a href="">EXPLORE</a> </div> </div> <div class="pic02 pic-common"> <img src="images/b2.jpg" alt=""> </div> <div class="text02 text-common"> <h3>Library</h3> <p class="r1">Lorem Ipsum is simply dummy text of the printing and typesetting industry</p> <p class="r2">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p> <div class="btn-explore"> <a href="">EXPLORE</a> </div> </div> </div> <!-- 第二排图文混排 --> <div class="row2"> <div class="text03 text-common"> <h3>Library</h3> <p class="r1">Lorem Ipsum is simply dummy text of the printing and typesetting industry</p> <p class="r2">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p> <div class="btn-explore"> <a href="">EXPLORE</a> </div> </div> <div class="pic03 pic-common"> <img src="images/b3.jpg" alt=""> </div> <div class="text04 text-common"> <h3>Library</h3> <p class="r1">Lorem Ipsum is simply dummy text of the printing and typesetting industry</p> <p class="r2">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p> <div class="btn-explore"> <a href="">EXPLORE</a> </div> </div> <div class="pic04 pic-common"> <img src="images/b4.jpg" alt=""> </div> </div> </div> <!-- Gallery区域 --> <div class="gallery"> <div class="gallery-info"> <h3>GALLERY</h3> <div class="about-underline"></div> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</p> </div> <div class="gallery-content"> <dl> <dt> <img src="images/03-01.jpg" alt=""> </dt> <dd> <a href="">Science Lab</a> </dd> </dl> <dl> <dt> <img src="images/03-02.jpg" alt=""> </dt> <dd> <a href="">Indoor Stadium</a> </dd> </dl> <dl> <dt> <img src="images/03-03.jpg" alt=""> </dt> <dd> <a href="">Transportation</a> </dd> </dl> <dl> <dt> <img src="images/03-04.jpg" alt=""> </dt> <dd> <a href="">Kids Room</a> </dl> <dl> <dt> <img src="images/03-05.jpg" alt=""> </dt> <dd> <a href="">Meditation Classes</a> </dd> </dl> <dl> <dt> <img src="images/03-06.jpg" alt=""> </dt> <dd> <a href="">Kids Play Ground</a> </dd> </dl> </div> </div> <!-- 页脚 --> <footer> <p>©2016 imooc.com 京ICP备13046642号</p> </footer> </body> </html>
10
收起
正在回答
1回答
同学你好,写的非常不错,几乎没有优化的点。如下位置,可以不用设置浮动:
祝学习愉快!
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星