一、效果图:
三、布局二(各浏览器兼容性良好)
CSS Code复制内容到剪贴板九宫格布局 - 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;
- }
- "grid_wrapper">
- "grid">
- "#" title="1">1
- "#" title="2">2
- "#" title="3">3
- "#" title="4">4
- "#" title="5">5
- "#" title="6">6
- "#" title="7">7
- "#" title="8">8
- "#" title="9">9
IE6下兼容有问题,效果图如下:
三、布局二(各浏览器兼容性良好)
CSS Code复制内容到剪贴板九宫格布局 - 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;
- }
- "grid_wrapper">
-
- "#" title="1">1
- "#" title="2">2
- "#" title="3">3
- "#" title="4">4
- "#" title="5">5
- "#" title="6">6
- "#" title="7">7
- "#" title="8">8
- "#" title="9">9


