手写链接:https://www.llheng.com/img/index.html
实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> body{ display: flex; justify-content: space-around; } hr{ width: 200px; margin-left: 0; } .box1{ width: 200px; height: 200px; background-color: #708090; display: table-cell;/*box1 块元素垂直居中*/ vertical-align: middle; } .box11{ background-color: #FFF8DC; width: 100px; height: 100px; margin: auto; /*box1 块元素水平居中*/ text-align: center; /*a标签水平居中 */ } .box11 a{ line-height: 100px; /*a标签垂直居中 */ } .box2{ width: 200px; height: 200px; background-color: #2F4F4F; display: table-cell;/*文本垂直居中*/ vertical-align: middle; } .box21{ text-align: center;/*文本水平居中*/ color: #fff; } .box3{ width: 200px; height: 200px; background-color: #FFDAB9; display: table-cell; vertical-align: bottom; text-align: center; } ul{ padding:0; margin:0; } li{ list-style: none; display: inline;/*行内元素显示*/ } </style> </head> <body > <div> <div class="box1"> <div class="box11"><a >行内元素</a></div> </div> </div> <div> <div class="box2"> <div class="box21"><span>第一行文本</span><br><span>第二行文本</span></div> </div> </div> <div> <div class="box3"> <ul > <li><a href="">1</a></li> <li><a href="">2</a></li> <li><a href="">3</a></li> <li><a href="">4</a></li> </ul> </div> </div> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例