Heim Web-Frontend HTML-Tutorial IE6/IE7中li底部4px空隙的Bug

IE6/IE7中li底部4px空隙的Bug

Jul 21, 2016 pm 02:53 PM

当li的子元素中有浮动(float)时,IE6/IE7中

  • 元素的下面会产生4px空隙的bug。

    代码如下:

    <ul class="list">
    <li><div>vapour</div></li>
    <li><div>百度</div></li>
    <li><div>淘宝</div></li>
    <li><div>迅雷</div></li>
    </ul> 
    
    Nach dem Login kopieren

    经过测试发现:li的子元素浮动是这个bug产生的必要条件,这个bug产生的充要条件是li的子元素浮动并且li设置了 以下CSS属性之 一:width、height、zoom、padding-top、padding-bottom、margin-top、margin-bottom。

    知道了这个bug的产生条件,所以解决方法也就有了:
    方法1 :
    #list div设置clear:left|both,这时#list li不能设置width、height、zoom。


    方法2 :
    #list li设置float:left,这时#list li可以设置width、height、zoom。
    #list li设置clear:left|both,这时#list li不能设置width、height、zoom。


    方法3 :
    IE6/IE7的这个Bug可以通过给li中的div设置vertical-align:top|middle|bottom解决。太怪异了,只要加上vertical-align的值是三者之一即可。

    代码如下:

    <span style="color: #0000ff;"><!<span style="color: #ff00ff;">DOCTYPE html<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">html<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">head<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">meta <span style="color: #ff0000;">charset<span style="color: #0000ff;">="gb2312" <span style="color: #0000ff;">/>
    <span style="color: #0000ff;"><<span style="color: #800000;">title<span style="color: #0000ff;">>IE6/IE7中li底部3px的Bug<span style="color: #0000ff;"></<span style="color: #800000;">title<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">style <span style="color: #ff0000;">type<span style="color: #0000ff;">="text/css"<span style="color: #0000ff;">><span style="color: #800000;">
    ul <span style="color: #000000;">{<span style="color: #ff0000;"> margin<span style="color: #000000;">:<span style="color: #0000ff;"> 0<span style="color: #000000;">;<span style="color: #ff0000;"> padding<span style="color: #000000;">:<span style="color: #0000ff;"> 0<span style="color: #000000;">;<span style="color: #ff0000;"> list-style<span style="color: #000000;">:<span style="color: #0000ff;"> none<span style="color: #000000;">; <span style="color: #000000;">}<span style="color: #800000;">
    hr <span style="color: #000000;">{<span style="color: #ff0000;"> clear<span style="color: #000000;">:<span style="color: #0000ff;"> both<span style="color: #000000;">; <span style="color: #000000;">}<span style="color: #800000;">
    .list li <span style="color: #000000;">{<span style="color: #ff0000;"> width<span style="color: #000000;">:<span style="color: #0000ff;"> 420px<span style="color: #000000;">; <span style="color: #000000;">}<span style="color: #800000;">
    .list div <span style="color: #000000;">{<span style="color: #ff0000;"> float<span style="color: #000000;">:<span style="color: #0000ff;"> left<span style="color: #000000;">;<span style="color: #ff0000;"> width<span style="color: #000000;">:<span style="color: #0000ff;"> 400px<span style="color: #000000;">;<span style="color: #ff0000;"> height<span style="color: #000000;">:<span style="color: #0000ff;"> 24px<span style="color: #000000;">;<span style="color: #ff0000;"> background<span style="color: #000000;">:<span style="color: #0000ff;"> red<span style="color: #000000;">; <span style="color: #000000;">}<span style="color: #800000;">
    .v-top div <span style="color: #000000;">{<span style="color: #ff0000;"> vertical-align<span style="color: #000000;">:<span style="color: #0000ff;"> top<span style="color: #000000;">; <span style="color: #000000;">}<span style="color: #800000;">
    .v-middle div <span style="color: #000000;">{<span style="color: #ff0000;"> vertical-align<span style="color: #000000;">:<span style="color: #0000ff;"> middle<span style="color: #000000;">; <span style="color: #000000;">}<span style="color: #800000;">
    .v-bottom div <span style="color: #000000;">{<span style="color: #ff0000;"> vertical-align<span style="color: #000000;">:<span style="color: #0000ff;"> bottom<span style="color: #000000;">; <span style="color: #000000;">}
    <span style="color: #0000ff;"></<span style="color: #800000;">style<span style="color: #0000ff;">>
    <span style="color: #0000ff;"></<span style="color: #800000;">head<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">body<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">ul <span style="color: #ff0000;">class<span style="color: #0000ff;">="list"<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">li<span style="color: #0000ff;">><<span style="color: #800000;">div<span style="color: #0000ff;">>vapour<span style="color: #0000ff;"></<span style="color: #800000;">div<span style="color: #0000ff;">></<span style="color: #800000;">li<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">li<span style="color: #0000ff;">><<span style="color: #800000;">div<span style="color: #0000ff;">>百度<span style="color: #0000ff;"></<span style="color: #800000;">div<span style="color: #0000ff;">></<span style="color: #800000;">li<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">li<span style="color: #0000ff;">><<span style="color: #800000;">div<span style="color: #0000ff;">>淘宝<span style="color: #0000ff;"></<span style="color: #800000;">div<span style="color: #0000ff;">></<span style="color: #800000;">li<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">li<span style="color: #0000ff;">><<span style="color: #800000;">div<span style="color: #0000ff;">>迅雷<span style="color: #0000ff;"></<span style="color: #800000;">div<span style="color: #0000ff;">></<span style="color: #800000;">li<span style="color: #0000ff;">>
    <span style="color: #0000ff;"></<span style="color: #800000;">ul<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">hr <span style="color: #0000ff;">/>
    <span style="color: #0000ff;"><<span style="color: #800000;">ul <span style="color: #ff0000;">class<span style="color: #0000ff;">="list v-top"<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">li<span style="color: #0000ff;">><<span style="color: #800000;">div<span style="color: #0000ff;">>vapour<span style="color: #0000ff;"></<span style="color: #800000;">div<span style="color: #0000ff;">></<span style="color: #800000;">li<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">li<span style="color: #0000ff;">><<span style="color: #800000;">div<span style="color: #0000ff;">>百度<span style="color: #0000ff;"></<span style="color: #800000;">div<span style="color: #0000ff;">></<span style="color: #800000;">li<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">li<span style="color: #0000ff;">><<span style="color: #800000;">div<span style="color: #0000ff;">>淘宝<span style="color: #0000ff;"></<span style="color: #800000;">div<span style="color: #0000ff;">></<span style="color: #800000;">li<span style="color: #0000ff;">>
    <span style="color: #0000ff;"><<span style="color: #800000;">li<span style="color: #0000ff;">><<span style="color: #800000;">div<span style="color: #0000ff;">>迅雷<span style="color: #0000ff;"></<span style="color: #800000;">div<span style="color: #0000ff;">></<span style="color: #800000;">li>
    </ul>
    <hr />
    <ul class="list v-middle">
    <li><div>vapour</div></li>
    <li><div>百度</div></li>
    <li><div>淘宝</div></li>
    <li><div>迅雷</div></li>
    </ul>
    <hr />
    <ul class="list v-bottom">
    <li><div>vapour</div></li>
    <li><div>百度</div></li>
    <li><div>淘宝</div></li>
    <li><div>迅雷</div></li>
    </ul>
    </body>
    </html> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
    Nach dem Login kopieren

     

  • Erklärung dieser Website
    Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

    Heiße KI -Werkzeuge

    Undresser.AI Undress

    Undresser.AI Undress

    KI-gestützte App zum Erstellen realistischer Aktfotos

    AI Clothes Remover

    AI Clothes Remover

    Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

    Undress AI Tool

    Undress AI Tool

    Ausziehbilder kostenlos

    Clothoff.io

    Clothoff.io

    KI-Kleiderentferner

    AI Hentai Generator

    AI Hentai Generator

    Erstellen Sie kostenlos Ai Hentai.

    Heißer Artikel

    R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
    1 Monate vor By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Beste grafische Einstellungen
    1 Monate vor By 尊渡假赌尊渡假赌尊渡假赌
    Will R.E.P.O. Crossplay haben?
    1 Monate vor By 尊渡假赌尊渡假赌尊渡假赌

    Heiße Werkzeuge

    Notepad++7.3.1

    Notepad++7.3.1

    Einfach zu bedienender und kostenloser Code-Editor

    SublimeText3 chinesische Version

    SublimeText3 chinesische Version

    Chinesische Version, sehr einfach zu bedienen

    Senden Sie Studio 13.0.1

    Senden Sie Studio 13.0.1

    Leistungsstarke integrierte PHP-Entwicklungsumgebung

    Dreamweaver CS6

    Dreamweaver CS6

    Visuelle Webentwicklungstools

    SublimeText3 Mac-Version

    SublimeText3 Mac-Version

    Codebearbeitungssoftware auf Gottesniveau (SublimeText3)

    Was ist der Zweck des & lt; Fortschritts & gt; Element? Was ist der Zweck des & lt; Fortschritts & gt; Element? Mar 21, 2025 pm 12:34 PM

    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

    Was ist der Zweck des & lt; datalist & gt; Element? Was ist der Zweck des & lt; datalist & gt; Element? Mar 21, 2025 pm 12:33 PM

    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

    Was ist der Zweck des & lt; Meter & gt; Element? Was ist der Zweck des & lt; Meter & gt; Element? Mar 21, 2025 pm 12:35 PM

    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

    Was ist das Ansichtsfenster -Meta -Tag? Warum ist es wichtig für reaktionsschnelles Design? Was ist das Ansichtsfenster -Meta -Tag? Warum ist es wichtig für reaktionsschnelles Design? Mar 20, 2025 pm 05:56 PM

    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.

    Was ist der Zweck des & lt; iframe & gt; Etikett? Was sind die Sicherheitsüberlegungen bei der Verwendung? Was ist der Zweck des & lt; iframe & gt; Etikett? Was sind die Sicherheitsüberlegungen bei der Verwendung? Mar 20, 2025 pm 06:05 PM

    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.

    Ist HTML für Anfänger leicht zu lernen? Ist HTML für Anfänger leicht zu lernen? Apr 07, 2025 am 12:11 AM

    HTML ist für Anfänger geeignet, da es einfach und leicht zu lernen ist und schnell Ergebnisse sehen kann. 1) Die Lernkurve von HTML ist glatt und leicht zu beginnen. 2) Beherrschen Sie einfach die grundlegenden Tags, um Webseiten zu erstellen. 3) hohe Flexibilität und kann in Kombination mit CSS und JavaScript verwendet werden. 4) Reiche Lernressourcen und moderne Tools unterstützen den Lernprozess.

    Die Rollen von HTML, CSS und JavaScript: Kernverantwortung Die Rollen von HTML, CSS und JavaScript: Kernverantwortung Apr 08, 2025 pm 07:05 PM

    HTML definiert die Webstruktur, CSS ist für Stil und Layout verantwortlich, und JavaScript ergibt eine dynamische Interaktion. Die drei erfüllen ihre Aufgaben in der Webentwicklung und erstellen gemeinsam eine farbenfrohe Website.

    Was ist ein Beispiel für ein Start -Tag in HTML? Was ist ein Beispiel für ein Start -Tag in HTML? Apr 06, 2025 am 12:04 AM

    AnexampleofaTartingTaginHtmlis, die, die starttagsaresesinginhtmlastheyinitiateElements, definetheirtypes, andarecrucialForstructuringwebpages und -konstruktionsthedoms.

    See all articles