我的banner区域的图片和顶部区域不在一个页面,怎么设置banner区?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | *{ font-family : Microsoft YaHei UI; margin : 0px ; padding : 0px ; } . top { width : 100% ; position : relative ; background-color : #07cbc9 ; height : 60px ; } . top .top-image{ float : left ; margin-left : 50px ; } . top .auth{ float : right ; } . top .auth ul li{ list-style : none ; float : left ; margin-right : 20px ; margin-top : 20px ; text-align : center ; } . top .auth ul li:hover{ background-color : black ; } . top .auth ul li a{ text-decoration : none ; color : #ffffff ; } .banner{ width : 100px ; height : 600px ; text-align : center ; } .banner .banner-image{ width : 100% ; position : absolute ; text-align : center ; } .banner .topLayer{ position : absolute ; width : 100% ; height : 600px ; background-color : #000 ; opacity: 0.4 ; } |
5
收起
正在回答 回答被采纳积分+1
4回答
好帮手慕柯南
2019-10-26 18:01:29
同学你好!
这里老师对同学的css做了一下修改,由于修改地方较多,老师会在注释中说明为什么那里会进行修改,同学可以参考一下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | *{ font-family : Microsoft YaHei UI; margin : 0px ; padding : 0px ; } . top { width : 100% ; position : relative ; background-color : #07cbc9 ; height : 60px ; } . top .top-image{ float : left ; margin-left : 50px ; } . top .auth{ float : right ; } . top .auth ul li{ list-style : none ; float : left ; margin-right : 20px ; margin-top : 20px ; text-align : center ; } . top .auth ul li:hover{ background-color : black ; } . top .auth ul li a{ text-decoration : none ; color : #ffffff ; } .banner{ width : 100% ; height : 600px ; /* 这里不需要居中设置,表单区域是通过绝对定位来实现的居中以及显示在最上层的 */ /* text-align: center; */ } .banner .banner-image{ width : 100% ; height : 600px ; /* 这里推荐使用相对定位*/ /* position: absolute; */ position : relative ; text-align : center ; } .banner .topLayer{ position : absolute ; width : 100% ; height : 600px ; background-color : #000 ; opacity: 0.4 ; z-index : 1 ; /* 遮罩层使用了绝对定位,应该设置top,否则无法和图片重叠 ,top设置为导航栏的高度即可*/ top : 60px ; } |
如果我的回答解决了你的疑惑,请采纳,祝学习愉快~
Sherlock_Lzh
2019-10-26 17:32:23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | *{ font-family : Microsoft YaHei UI; margin : 0px ; padding : 0px ; } . top { width : 100% ; position : relative ; background-color : #07cbc9 ; height : 60px ; } . top .top-image{ float : left ; margin-left : 50px ; } . top .auth{ float : right ; } . top .auth ul li{ list-style : none ; float : left ; margin-right : 20px ; margin-top : 20px ; text-align : center ; } . top .auth ul li:hover{ background-color : black ; } . top .auth ul li a{ text-decoration : none ; color : #ffffff ; } .banner{ width : 100% ; height : 600px ; text-align : center ; } .banner .banner-image{ width : 100% ; height : 600px ; position : absolute ; text-align : center ; } .banner .topLayer{ position : absolute ; width : 100% ; height : 600px ; background-color : #000 ; opacity: 0.4 ; z-index : 1 ; } |
Sherlock_Lzh
2019-10-26 17:31:55
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | <!DOCTYPE html> < html > < head > < title >作业</ title > < link rel = "stylesheet" type = "text/css" href = "css/test.css" > < script type = "text/javascript" src = "js/biancheng.js" ></ script > </ head > < body > < div class = "top" > < div class = "top-image" > < a href = "https://class.imooc.com" class = "ccl" >< img src = "images/logo.png" ></ a > </ div > < div class = "auth" > < ul > < li >< a href = "#" class = "cl" >HOME</ a ></ li > < li >< a href = "#" class = "cl" >ABOUT</ a ></ li > < li >< a href = "#" class = "cl" >GALLERY</ a ></ li > < li >< a href = "#" class = "cl" >FACULTY</ a ></ li > < li >< a href = "#" class = "cl" >EVENTS</ a ></ li > < li >< a href = "#" class = "cl" >CONTACT</ a ></ li > </ ul > </ div > </ div > < div class = "banner" > < div class = "banner-image" > < img src = "images/banner3.jpg" class = "banner-image" > </ div > < div class = "topLayer" > </ div > < div class = "biaodan" > < form action = "" method = "" > < input type = "text" name = "" id = "" value = "your Name" > < input type = "text" name = "" id = "" value = "your Phone" > < input type = "text" name = "" id = "" value = " your Emile" > < input type = "text" name = "" id = "" value = "Write Your Comment Here" > < input type = "text" name = "" id = "" value = "SEND MESSAGE" > </ form > </ div > </ div > < div class = "ABOUT" > </ div > < div class = "GALLERY" > </ div > < div class = "foot" > </ div > </ body > </ html > |
2. 从网页搭建入门JavaWeb
- 参与学习 人
- 提交作业 676 份
- 解答问题 9666 个
本阶段将从前端网页搭建入手,到Java Web基础,前后端结合助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧