我的页面上有一些链接。这些链接由边框包围,并为它们设置背景。它们基本上都在一个盒子里。
<!DOCTYPE html>
<style>
a {
background: #DDD;
border: #BBB;
padding:1px;
width: 20em; /*no effect*/
height: 2em; /*no effect*/
}
</style>
<a href="http://stackoverflow.com">1</a>
<a href="http://stackoverflow.com">1111111111111</a>
如何让这些盒子具有相同的尺寸?
答案 0 :(得分:1)
不太了解但是如果你想要相同大小的包装器而不仅仅使用display: block;
,因为<a>
是一个内联元素,因此你需要使它成为块级元素,或者如果你想要块内联,只需使用display: inline-block;
<style>
a {
background: #DDD;
border: #BBB;
padding:1px;
width: 20em;
height: 2em;
display: block; <------ Add This
}
</style>