1.如何讓文字水平垂直居中?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>css練習</title> <style> a { /* 行內元素轉行內塊級元素,因為行內元素無法改變寬高,若想改變,必須先轉成行內塊級元素 */ display: inline-block; width: 70px; /* 行高等於高度,文字才會垂直居中 */ height: 30px; line-height: 30px; background-color: aqua; /* 去掉下划線 */ text-decoration: none; /* 設置水平居中 */ text-align: center; } /* 鼠標滑過效果 */ a:hover { color: #ff00ff; background-color: #fff; } </style> </head> <body> <a href="#">新聞</a> <a href="#">體育</a> <a href="#">新浪</a> </body> </html>
2.如何測試行高?
ps中有個切片工具