h5自适应的九宫格(图片,文字...) ,适配所有的手机
1.body代码:
<div id="test"> <a><div>1</div> </a> <a><div>2</div> </a> <a><div>3</div> </a> <a><div>4</div> </a> <a><div>5</div> </a> <a><div>6</div> </a> <a><div>7</div> </a> <a><div>8</div> </a> <a><div>9</div> </a> </div>
2.css.
#test div{ width: calc(100% - 13px); line-height: 50px; text-align:center; background: #AAA; margin-top: 13px; } #test a{ width: calc((100% - 13px) / 3); //如果是6宫格,就➗2 就可以了 line-height: 55px; float: left; text-decoration: none; padding-left: 13px; padding-bottom: 13px; margin-right: -13px; margin-bottom: -13px; } #test a:hover{ background: red; }