<!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 is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools