<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>CSS等高布局</title><script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script> <style type="text/css">#wrap{ overflow:hidden; width:1200px; margin:0 auto;}.top{ width:1200px; height:150px; background:#000; margin-bottom: 10px; } .left{ float:left; width:150px; height:600px ; background:#00FFFF; }#center{ float:left; width:880px; height:1800px ; background:#FF0000; margin-right: 10px; margin-left: 10px; }.right{ float:right; width:150px; height:600px ; background:#00FF00; } .bot{ width:1200px; height:150px; margin-top: 10px; background-color: #00F; } </style></head><body><div id="wrap"> <div class="top"> </div> <div class="left" id="left" > </div> <div id="center"> <p>center</p><p>center2</p><p>center3</p><p>center4</p><p>center5</p><p>center6</p><p>center7</p> </div> <div class="right" id="right"> </div> <div class="bot"> </div> </div><script>var min_scroll=30;///触发效果的滚动条top值,$(document).scroll(function(){ if($(this).scrollTop()>=min_scroll&&!$('#left').attr('style')) { var right={'top':$('#right').offset().top,'left':$('#right').offset().left}; var left={'top':$('#left').offset().top,'left':$('#left').offset().left}; var center={'left':$('#center').position().left} $('#center').css({'position':'absolute','left':center.left}); $('#left').css({'z-index':10,'position':'fixed','top':left.top,'left':left.left}); $('#right').css({'z-index':10,'position':'fixed','top':right.top,'left':right.left}); } if($(this).scrollTop()<min_scroll&&$('#left').attr('style')) { $('#left').removeAttr('style'); $('#right').removeAttr('style'); $('#center').removeAttr('style'); } });</script> </body></html>
效果就是这样,但是加入头部,和底部后,就变形了,两边的滚动那个上面永远有顶部高度的距离,想把这个距离去掉,另外底部自动跳到顶部的下面的。
回复讨论(解决方案)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>CSS等高布局</title><script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script> <style type="text/css">#wrap{ overflow:hidden; width:1200px; margin:0 auto;}.top{ width:1200px; height:150px; background:#000; margin-bottom: 10px; } .left{ float:left; width:150px; height:600px ; background:#00FFFF; }#center{ float:left; width:880px; height:1800px ; background:#FF0000; margin-right: 10px; margin-left: 10px; }.right{ float:right; width:150px; height:600px ; background:#00FF00; } .bot{ float:left; width:1200px; height:150px; margin-top: 10px; background-color: #00F; } </style></head><body><div id="wrap"> <div class="top"> </div> <div class="left" id="left" > </div> <div id="center"> <p>center</p><p>center2</p><p>center3</p><p>center4</p><p>center5</p><p>center6</p><p>center7</p><p>center8</p><p>center9</p><p>center10</p> </div> <div class="right" id="right"> </div> <div class="bot" id="bot"> </div> </div><script>var min_scroll=30;///触发效果的滚动条top值,$(document).scroll(function(){ if($(this).scrollTop()>=min_scroll&&!$('#left').attr('style')) { var right={'top':0,'left':$('#right').offset().left}; var left={'top':0,'left':$('#left').offset().left}; var center={'left':$('#center').position().left} var bot={'top':0,'left':$('#bot').offset().left} $('#bot').css({'position':'fixed','left':bot.left,'top':bot.top,'margin':0}); $('#center').css({'position':'absolute','left':center.left}); $('#left').css({'z-index':10,'position':'fixed','top':left.top,'left':left.left}); $('#right').css({'z-index':10,'position':'fixed','top':right.top,'left':right.left}); } if($(this).scrollTop()<min_scroll&&$('#left').attr('style')) { $('#left').removeAttr('style'); $('#bot').removeAttr('style'); $('#right').removeAttr('style'); $('#center').removeAttr('style'); } });</script> </body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>CSS等高布局</title><script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script> <style type="text/css">#wrap{ overflow:hidden; width:1200px; margin:0 auto;}.top{ width:1200px; height:150px; background:#000; margin-bottom: 10px; } .left{ float:left; width:150px; height:600px ; background:#00FFFF; }#center{ float:left; width:880px; height:1800px ; background:#FF0000; margin-right: 10px; margin-left: 10px; }.right{ float:right; width:150px; height:600px ; background:#00FF00; } .bot{ float:left; width:1200px; height:150px; margin-top: 10px; background-color: #00F; } </style></head><body><div id="wrap"> <div class="top"> </div> <div class="left" id="left" > </div> <div id="center"> <p>center</p><p>center2</p><p>center3</p><p>center4</p><p>center5</p><p>center6</p><p>center7</p><p>center8</p><p>center9</p><p>center10</p> </div> <div class="right" id="right"> </div> <div class="bot" id="bot"> </div> </div><script>var min_scroll=30;///触发效果的滚动条top值,$(document).scroll(function(){ if($(this).scrollTop()>=min_scroll&&!$('#left').attr('style')) { var right={'top':0,'left':$('#right').offset().left}; var left={'top':0,'left':$('#left').offset().left}; var center={'left':$('#center').position().left} var bot={'top':0,'left':$('#bot').offset().left} $('#bot').css({'position':'fixed','left':bot.left,'top':bot.top,'margin':0}); $('#center').css({'position':'absolute','left':center.left}); $('#left').css({'z-index':10,'position':'fixed','top':left.top,'left':left.left}); $('#right').css({'z-index':10,'position':'fixed','top':right.top,'left':right.left}); } if($(this).scrollTop()<min_scroll&&$('#left').attr('style')) { $('#left').removeAttr('style'); $('#bot').removeAttr('style'); $('#right').removeAttr('style'); $('#center').removeAttr('style'); } });</script> </body></html>
底部的BOT还是会把CENTER档上
你想哪个叠哪个 z-index就是表示他们重叠是时候显示的顺序,越大越在上面
你最好先理解下position的absolute,fixed还有与position搭配的top,bottom,left,right,z-index
你想哪个叠哪个 z-index就是表示他们重叠是时候显示的顺序,越大越在上面
我想想让bot不重叠,显示在最下面 谢谢了

HTML是构建网页结构的基石。1.HTML定义内容结构和语义,使用、、等标签。2.提供语义化标记,如、、等,提升SEO效果。3.通过标签实现用户交互,需注意表单验证。4.使用、等高级元素结合JavaScript实现动态效果。5.常见错误包括标签未闭合和属性值未加引号,需使用验证工具。6.优化策略包括减少HTTP请求、压缩HTML、使用语义化标签等。

HTML是一种用于构建网页的语言,通过标签和属性定义网页结构和内容。1)HTML通过标签组织文档结构,如、。2)浏览器解析HTML构建DOM并渲染网页。3)HTML5的新特性如、、增强了多媒体功能。4)常见错误包括标签未闭合和属性值未加引号。5)优化建议包括使用语义化标签和减少文件大小。

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

HTML的作用是通过标签和属性定义网页的结构和内容。1.HTML通过到、等标签组织内容,使其易于阅读和理解。2.使用语义化标签如、等增强可访问性和SEO。3.优化HTML代码可以提高网页加载速度和用户体验。

htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代码” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代码”代码“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract

HTML、CSS和JavaScript是Web开发的三大支柱。1.HTML定义网页结构,使用标签如、等。2.CSS控制网页样式,使用选择器和属性如color、font-size等。3.JavaScript实现动态效果和交互,通过事件监听和DOM操作。

HTML定义网页结构,CSS负责样式和布局,JavaScript赋予动态交互。三者在网页开发中各司其职,共同构建丰富多彩的网站。

HTML适合初学者学习,因为它简单易学且能快速看到成果。1)HTML的学习曲线平缓,易于上手。2)只需掌握基本标签即可开始创建网页。3)灵活性高,可与CSS和JavaScript结合使用。4)丰富的学习资源和现代工具支持学习过程。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

Atom编辑器mac版下载
最流行的的开源编辑器

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

禅工作室 13.0.1
功能强大的PHP集成开发环境