高手们,我这代码运行时为什么出错_html/css_WEB-ITnose
<!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不重叠,显示在最下面 谢谢了

Heiße KI -Werkzeuge

Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool
Ausziehbilder kostenlos

Clothoff.io
KI-Kleiderentferner

AI Hentai Generator
Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

Heiße Werkzeuge

Notepad++7.3.1
Einfach zu bedienender und kostenloser Code-Editor

SublimeText3 chinesische Version
Chinesische Version, sehr einfach zu bedienen

Senden Sie Studio 13.0.1
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver CS6
Visuelle Webentwicklungstools

SublimeText3 Mac-Version
Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

Heiße Themen



Der Artikel erörtert den HTML & lt; Progress & gt; Element, Absicht, Styling und Unterschiede vom & lt; Meter & gt; Element. Das Hauptaugenmerk liegt auf der Verwendung & lt; Fortschritt & gt; Für Aufgabenabschluss und & lt; Meter & gt; für stati

Der Artikel erörtert den HTML & lt; Datalist & gt; Element, das die Formulare verbessert, indem automatische Vorschläge bereitgestellt, die Benutzererfahrung verbessert und Fehler reduziert werden.Character Count: 159

Der Artikel erörtert das HTML & lt; Meter & gt; Element, verwendet zur Anzeige von Skalar- oder Bruchwerten innerhalb eines Bereichs und seine gemeinsamen Anwendungen in der Webentwicklung. Es differenziert & lt; Meter & gt; von & lt; Fortschritt & gt; und Ex

In dem Artikel wird das Ansichtsfenster -Meta -Tag erörtert, das für das reaktionsschnelle Webdesign auf mobilen Geräten unerlässlich ist. Es wird erläutert, wie die ordnungsgemäße Verwendung eine optimale Skalierung von Inhalten und Benutzerinteraktion gewährleistet, während Missbrauch zu Design- und Zugänglichkeitsproblemen führen kann.

In Artikel werden Best Practices zur Gewährleistung der HTML5-Cross-Browser-Kompatibilität erörtert und sich auf die Erkennung von Merkmalen, die progressive Verbesserung und die Testmethoden konzentriert.

Dieser Artikel erklärt den HTML5 & lt; Time & gt; Element für semantische Datum/Uhrzeit. Es betont die Wichtigkeit des DateTime-Attributs für die Maschinenlesbarkeit (ISO 8601-Format) neben menschenlesbarem Text, das Zubehör steigert

In dem Artikel werden unter Verwendung von HTML5 -Formularvalidierungsattributen wie Erforderlich, Muster, Min, MAX und Längengrenzen erörtert, um die Benutzereingabe direkt im Browser zu validieren.

Der Artikel erörtert das & lt; iframe & gt; Der Zweck von Tag, externe Inhalte in Webseiten, seine gemeinsamen Verwendungen, Sicherheitsrisiken und Alternativen wie Objekt -Tags und APIs einzubetten.
