解決方法是加上行高line-height
(此例子爲靜態例子,動態創建的元素的解決方法一樣。)
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title></title>
- <style type="text/css">
- .test li a
- {
- line-height: 1.5em; /*添加行高*/
- color: #2763ad;
- font-size: 12px;
- text-decoration: none;
- border-bottom: 1px solid #2763ad;
- }
- .test li a:hover
- {
- text-decoration: none;
- border-bottom: none;
- }
- </style>
- </head>
- <body>
- <ul class="test">
- <li><a href="#">測試內容</a> </li>
- </ul>
- </body>
- </html>