解决方法是加上行高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>