Maison > interface Web > tutoriel CSS > le corps du texte

Une démonstration simple de l'utilisation de CSS pour implémenter une disposition en grille de neuf carrés sur une page

不言
Libérer: 2018-06-05 15:50:11
original
4004 Les gens l'ont consulté

La disposition en grille à neuf carrés est souvent utilisée lors de la création de certaines applications Web. Nous utilisons ici un exemple structurel approximatif comme simple démonstration de l'implémentation CSS de la disposition en grille à neuf carrés sur la page. attention aux problèmes de compatibilité sous IE6.

1. Rendu :
2016627113915155.jpg (175×173)

3. Mise en page 2 (compatible avec tous les navigateurs Bonnes performances)

Code CSSCopiez le contenu dans le presse-papiers

<!DOCTYPE html>   
<html>   
<head>   
<meta charset="utf-8">   
<title>九宫格布局</title>   
<meta http-equiv="X-UA-Compatible" content="IE=edge">   
</head>   
<body>   
<html>   
<head>   
<style type="text/css">   
body{margin:0;padding:0;}   
.grid_wrapper{   
 width: 170px;   
 height: 170px;   
 margin-left: auto;   
 margin-right: auto;   
}   
.grid{   
 margin-left: 5px;   
 margin-top: 5px;   
}   
.grid:after{   
 content: ".";   
 display: block;   
 line-height: 0;   
 height: 0;   
 clear: both;   
 visibility: hidden;   
 overflow: hidden;   
}   
.grid a,.grid a:visited{   
 float: left;   
 display: inline;   
 border: 5px solid #ccc;   
 width: 50px;   
 height: 50px;   
 text-align: center;   
 line-height: 50px;   
 margin-left: -5px;   
 margin-top: -5px;   
 position: relative;   
 z-index: 1;   
}   
.grid a:hover{   
 border-color: #f00;   
 z-index: 2;   
}   
</style>   
</head>   
<body>   
<p class="grid_wrapper">   
 <p class="grid">   
  <a href="#" title="1">1</a>   
  <a href="#" title="2">2</a>   
  <a href="#" title="3">3</a>   
  <a href="#" title="4">4</a>   
  <a href="#" title="5">5</a>   
  <a href="#" title="6">6</a>   
  <a href="#" title="7">7</a>   
  <a href="#" title="8">8</a>   
  <a href="#" title="9">9</a>   
 </p>   
</p>   
</body>   
</html>
Copier après la connexion

Il y a un problème de compatibilité sous IE6 Le rendu est le suivant :
2016627114120994.jpg (175×228)

3 (bonne compatibilité entre navigateurs)

<. 🎜>Code CSSCopier le contenu dans le Presse-papiers

<!DOCTYPE html>   
<html>   
<head>   
<meta charset="utf-8">   
<title>九宫格布局</title>   
<meta http-equiv="X-UA-Compatible" content="IE=edge">   
</head>   
<body>   
<html>   
<head>   
<style type="text/css">   
body,ul,li{margin:0;padding:0;}   
.grid_wrapper{   
 width: 170px;   
 height: 170px;   
 margin-left: auto;   
 margin-right: auto;   
}   
.grid{   
 margin-left: 5px;   
 margin-top: 5px;   
 list-style-type:none;   
}   
.grid:after{   
 content: ".";   
 display: block;   
 line-height: 0;   
 width:0;   
 height: 0;   
 clear: both;   
 visibility: hidden;   
 overflow: hidden;   
}   
.grid li{float:left;line-height: 50px;}   
.grid li a,.grid li a:visited{   
 display:block;   
 border: 5px solid #ccc;   
 width: 50px;   
 height: 50px;   
 text-align: center;   
 margin-left: -5px;   
 margin-top: -5px;   
 position: relative;   
 z-index: 1;   
}   
.grid li a:hover{   
 border-color: #f00;   
 z-index: 2;   
}   
</style>   
</head>   
<body>   
<p class="grid_wrapper">   
 <ul class="grid">   
  <li><a href="#" title="1">1</a></li>   
  <li><a href="#" title="2">2</a></li>   
  <li><a href="#" title="3">3</a></li>   
  <li><a href="#" title="4">4</a></li>   
  <li><a href="#" title="5">5</a></li>   
  <li><a href="#" title="6">6</a></li>   
  <li><a href="#" title="7">7</a></li>   
  <li><a href="#" title="8">8</a></li>   
  <li><a href="#" title="9">9</a></li>   
 </ul>   
</p>   
</body>   
</html>
Copier après la connexion
Recommandations associées :


Implémentation CSS du code d'effet de menu standard WEB avec une marque de triangle inversé

Créez des images arrondies et des images ovales avec CSS3


Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Étiquettes associées:
source:php.cn
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
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!