Maison interface Web tutoriel HTML 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> 
    
    Copier après la connexion

    经过测试发现: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>
    Copier après la connexion

     

  • Déclaration de ce site Web
    Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn

    Outils d'IA chauds

    Undresser.AI Undress

    Undresser.AI Undress

    Application basée sur l'IA pour créer des photos de nu réalistes

    AI Clothes Remover

    AI Clothes Remover

    Outil d'IA en ligne pour supprimer les vêtements des photos.

    Undress AI Tool

    Undress AI Tool

    Images de déshabillage gratuites

    Clothoff.io

    Clothoff.io

    Dissolvant de vêtements AI

    AI Hentai Generator

    AI Hentai Generator

    Générez AI Hentai gratuitement.

    Article chaud

    R.E.P.O. Crystals d'énergie expliqués et ce qu'ils font (cristal jaune)
    1 Il y a quelques mois By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Meilleurs paramètres graphiques
    1 Il y a quelques mois By 尊渡假赌尊渡假赌尊渡假赌
    Will R.E.P.O. Vous avez un jeu croisé?
    1 Il y a quelques mois By 尊渡假赌尊渡假赌尊渡假赌

    Outils chauds

    Bloc-notes++7.3.1

    Bloc-notes++7.3.1

    Éditeur de code facile à utiliser et gratuit

    SublimeText3 version chinoise

    SublimeText3 version chinoise

    Version chinoise, très simple à utiliser

    Envoyer Studio 13.0.1

    Envoyer Studio 13.0.1

    Puissant environnement de développement intégré PHP

    Dreamweaver CS6

    Dreamweaver CS6

    Outils de développement Web visuel

    SublimeText3 version Mac

    SublimeText3 version Mac

    Logiciel d'édition de code au niveau de Dieu (SublimeText3)

    Quel est le but du & lt; Progress & gt; élément? Quel est le but du & lt; Progress & gt; élément? Mar 21, 2025 pm 12:34 PM

    L'article traite du HTML & lt; Progress & GT; élément, son but, son style et ses différences par rapport au & lt; mètre & gt; élément. L'objectif principal est de l'utiliser & lt; Progress & gt; pour l'achèvement des tâches et & lt; mètre & gt; pour stati

    Quel est le but du & lt; datalist & gt; élément? Quel est le but du & lt; datalist & gt; élément? Mar 21, 2025 pm 12:33 PM

    L'article traite du HTML & lt; Datalist & GT; élément, qui améliore les formulaires en fournissant des suggestions de saisie semi-automatique, en améliorant l'expérience utilisateur et en réduisant les erreurs. COMMANDE COMPRES: 159

    Quel est le but du & lt; mètre & gt; élément? Quel est le but du & lt; mètre & gt; élément? Mar 21, 2025 pm 12:35 PM

    L'article traite du HTML & lt; mètre & gt; élément, utilisé pour afficher des valeurs scalaires ou fractionnaires dans une plage, et ses applications courantes dans le développement Web. Il différencie & lt; mètre & gt; De & lt; Progress & gt; et ex

    Quelle est la balise Meta de la fenêtre? Pourquoi est-ce important pour une conception réactive? Quelle est la balise Meta de la fenêtre? Pourquoi est-ce important pour une conception réactive? Mar 20, 2025 pm 05:56 PM

    L'article traite de la balise Meta de la fenêtre, essentielle pour la conception Web réactive sur les appareils mobiles. Il explique comment une utilisation appropriée garantit une mise à l'échelle optimale du contenu et une interaction utilisateur, tandis que la mauvaise utilisation peut entraîner des problèmes de conception et d'accessibilité.

    Quel est le but du & lt; iframe & gt; étiqueter? Quelles sont les considérations de sécurité lorsque vous l'utilisez? Quel est le but du & lt; iframe & gt; étiqueter? Quelles sont les considérations de sécurité lorsque vous l'utilisez? Mar 20, 2025 pm 06:05 PM

    L'article traite du & lt; iframe & gt; L'objectif de Tag dans l'intégration du contenu externe dans les pages Web, ses utilisations courantes, ses risques de sécurité et ses alternatives telles que les balises d'objet et les API.

    HTML est-il facile à apprendre pour les débutants? HTML est-il facile à apprendre pour les débutants? Apr 07, 2025 am 12:11 AM

    HTML convient aux débutants car il est simple et facile à apprendre et peut rapidement voir les résultats. 1) La courbe d'apprentissage de HTML est fluide et facile à démarrer. 2) Il suffit de maîtriser les balises de base pour commencer à créer des pages Web. 3) Flexibilité élevée et peut être utilisée en combinaison avec CSS et JavaScript. 4) Les ressources d'apprentissage riches et les outils modernes soutiennent le processus d'apprentissage.

    Les rôles de HTML, CSS et JavaScript: responsabilités de base Les rôles de HTML, CSS et JavaScript: responsabilités de base Apr 08, 2025 pm 07:05 PM

    HTML définit la structure Web, CSS est responsable du style et de la mise en page, et JavaScript donne une interaction dynamique. Les trois exercent leurs fonctions dans le développement Web et construisent conjointement un site Web coloré.

    Quel est un exemple d'une balise de départ dans HTML? Quel est un exemple d'une balise de départ dans HTML? Apr 06, 2025 am 12:04 AM

    Anexampleofastartingtaginhtmlis, qui abinginsaparagraph.startingtagsaressentialtinhtmlastheyinitiateelements, définit les éventualités, et la faculté de réduction des pages et de la construction de la création.

    See all articles