答案 0 :(得分:0)
制作你的主播display:block
并将填充从li
.menu li a {
display:block;
padding: 8px;
}
display:block
将a
转换为块级元素,占用其父级的整个不动产。
.menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.menu li {
margin-bottom: 7px;
background-color: #2D74B4;
color: #ffffff;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
text-align: center;
}
.menu li:hover {
background-color: #0099cc;
}
.menu li a {
display:block;
padding: 8px;
}
a:link {color: #ffffff; text-decoration: none;}
a:visited {color: #ffffff; text-decoration: none;}
a:hover {color: #ffffff; text-decoration: none;}
a:active {color: #ffffff; text-decoration: none;}

<div class="menu">
<ul>
<li><a href="#">test</a></li>
<li><a href="#">test</a></li>
<li><a href="#">test</a></li>
<li><a href="#">test</a></li>
<li><a href="#">test</a></li>
<li><a href="#">test</a></li>
<li><a href="#">test</a></li>
</ul>
</div>
&#13;
答案 1 :(得分:-1)
使用block
“封闭”按钮,填充应该在里面。
a { display:block; padding: 8px; }
a:link {color: #ffffff; text-decoration: none;}
a:visited {color: #ffffff; text-decoration: none;}
a:hover {color: #ffffff; text-decoration: none;}
a:active {color: #ffffff; text-decoration: none;}
轻松自在!