这里的右侧导航条在第一屏里随页面滚动,在第二屏就消失了, 请指教~
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 | <!DOCTYPE html> <html> <head> <meta charset= "UTF-8" > <title>分屏网页</title> <link rel= "stylesheet" type= "text/css" href= "css/style.css" > <script type= "text/javascript" src= "js/index.js" ></script> </head> <body> <!--头部--> <div class= "box" > <header class= "header" > <div class= "header_wrap" > <div class= "header_logo" >H 5 实战页面</div> <nav class= "header_nav" > <a href= "#" class= "header_nav-item header_nav-item_status_active" >实战课程</a> <a href= "#" class= "header_nav-item" >商业案例</a> <a href= "#" class= "header_nav-item" >课程体系</a> <a href= "#" class= "header_nav-item" >集成环境</a> <a href= "#" class= "header_nav-item" >云端学习</a> <a href= "#" class= " header_nav-item_custom_button" >即刻学习</a> </nav> </div> </header> <!--标签--> <div class= "outline" > <a href= "#" class= "outline-item" >实</a> <a href= "#" class= "outline-item" >商</a> <a href= "#" class= "outline-item" >课</a> <a href= "#" class= "outline-item" >环</a> <a href= "#" class= "outline-item" >云</a> </div> <!--第一屏--> <div class= "screen-1" > <div class= "screen-1_heading" > <h 2 >实战课程重磅上线</h 2 > <p>一键云学习,还在等待什么?</p> </div> </div> <!--第二屏--> <div class= "screen-2" > <div class= "screen-2_wrap" > <h 2 class= "screen-2_heading" >每门课都是真实商业案例</h 2 > <h 6 class= "screen-2_subheading" >真实案例,真实场景,在实战中实践、操作、调试<br>大牛带你体验BAT真实开发流程,所有开发过程一一为你呈现</h 6 > <div class= "screen-2_photo" > <div class= "screen-2_photo-1" ></div> <div class= "screen-2_photo-2" ></div> </div> </div> </div> </div> </body> </html> |
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | *{ margin : 0 ; padding : 0 ; } /*头部导航条*/ .box{ position : relative ; } .header{ width : 100% ; background :linear-gradient( black , transparent ); position : fixed ; top : 0 ; } .header_wrap{ width : 1200px ; height : 80px ; margin : 0 auto ; position : relative ; } .header_logo{ width : 200px ; height : 39px ; line-height : 39px ; font-size : 20px ; color : white ; text-indent : 50px ; background : url ( '../img/logo.png' ) left center no-repeat ; background- size : 39px 39px ; position : absolute ; top : 50% ; margin-top : -20px ; left : 20px ; } .header_logo:hover{ color : #f01044 ; cursor : pointer ; } .header_nav{ position : absolute ; right : 20px ; height : 39px ; top : 50% ; margin-top : -20px ; } .header_nav-item{ color : white ; font-size : 14px ; display : block ; height : 39px ; line-height : 39px ; float : left ; position : relative ; width : 59px ; text-align : center ; margin-left : 44px ; text-decoration : none ; } .header_nav-item:hover{ height : 45px ; cursor : pointer ; border-bottom : 2px solid #f00 ; } .header_nav-item_status_active{ color : red ; height : 45px ; border-bottom : 2px solid #f00 ; } .header_nav-item_custom_button{ background : #f01400 ; color : #fbf0ff ; text-align : center ; width : 99px ; margin-left : 40px ; padding : 0 ; border-radius: 3px ; color : black ; font-size : 14px ; display : block ; height : 39px ; line-height : 39px ; float : left ; position : relative ; text-decoration : none ; } .header_nav-item_custom_button:hover{ background : #ff5511 ; } /*标签*/ .outline{ width : 40px ; height : 150px ; background : #fff ; position : fixed ; right : 0 ; bottom : 200px ; } .outline-item{ margin : 6px 0 ; color : #000 ; text-decoration : none ; text-align : center ; display : block ; } /*第一屏*/ .screen -1 { height : 640px ; width : 100% ; background : url (../img/sc 1 .jpg) center center no-repeat ; background- size : cover; } .screen -1 _heading{ padding : 0 ; margin : 0 ; width : 100% ; height : 640px ; display : block ; text-align : center ; position : absolute ; top : 320px ; margin-top : -12px ; font-size : 24px ; color : white ; } .screen -1 _heading p{ font-size : 16px ; margin-top : 29px ; } /*第二屏*/ .screen -2 { background-color : #f3f5f7 ; position : relative ; } .screen -2 _wrap{ width : 1200px ; height : 640px ; } .screen -2 _heading{ font-weight : normal ; margin : 0 ; padding : 0 ; font-size : 44px ; line-height : 44px ; color : #000000 ; padding-top : 90px ; text-align : center ; } .screen -2 _heading::after{ content : " " ; display : block ; height : 2px ; width : 52px ; margin-top : 36px ; background-color : #ff0000 ; position : absolute ; left : 50% ; margin-left : -26px ; } .screen -2 _subheading{ font-weight : normal ; margin : 0 ; padding : 0 ; font-size : 13px ; line-height : 26px ; color : #2c3137 ; padding-top : 50px ; text-align : center ; } .screen -2 _photo{ width : 740px ; height : 362px ; background : url (../img/sc 2 .png) no-repeat ; background-position : cover; position : absolute ; bottom : 0 ; left : 50% ; margin-left : -370px ; z-index : 0 ; } .screen -2 _photo -1 { width : 277px ; height : 383px ; background : url (../img/sc 2 -1 .png) no-repeat ; position : absolute ; bottom : 0 ; left : 50% ; margin-left : -134px ; z-index : 2 ; } .screen -2 _photo -2 { width : 266px ; height : 205px ; background : url (../img/sc 2 -2 .png) no-repeat ; position : absolute ; top : 56px ; left : 50% ; z-index : 1 ; } /*第三屏*/ .screen -3 { width : 100% ; height : 640px ; background-color : #2b333b ; } .screen -3 _bg |
0
收起
正在回答
2回答
同学你好,原因是标题下面红色的线是绝对定位,因为.screen-2设置了定位,所以是根据.screen-2来进行定位的,.screen-2的宽度为100%,所以会出现这种情况。
建议:给父级设置相对定位。代码参考:
如果还有其他疑问,建议在问答区重新提问,便于同学后期查找总结
如果我的回答帮到了你,欢迎采纳,祝学习愉快~
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧