我想要的只是将第二个框中的按钮显示为块元素,以便它扩展以填充容器 - 但是当我将按钮元素设置为 display:block 时 - 它会溢出容器(父级),请参阅下列的:
http://jsfiddle.net/MgcDU/7747/
有任何想法吗?我错过了什么?
我的 CSS:
a:link { color:#0040FF;text-decoration:none; }
a:visited { color:#0040FF; }
a:hover { background-color:#82B6EA;color:#FFFFFF;text-decoration:none; }
a:active { color:#0040FF; }
body { color:black;font-style:normal;font-size:10pt;font-family:Arial, Helvetica, sans-serif;padding:0;margin:0; }
.body_1 { margin-top:10px;margin-left:20px;margin-right:20px;margin-bottom:10px; }
.grid_1 { margin:8px 0 0 0;padding:0;overflow:hidden; }
.grid_1_left { float:left;width:240px;margin:0;padding:0; }
.grid_1_right { margin:0 0 0 245px;padding:0 0 0 8px; }
.grid_1_right_bld { margin:0 0 0 245px;padding:0 0 0 8px;border-left:2px #AAAAAA dotted; }
.btn, a.btn
{
background-color:#D3D7D7;color:#333333;display:inline-block;padding:6px 12px;margin-bottom:0;text-align:center;white-space:nowrap;vertical-align:middle;
cursor:pointer;border:1px solid transparent;border-color:#D3D7D7;
-webkit-transition:border-color 0.3s ease-out, background-color 0.3s ease-out;
-moz-transition:border-color 0.3s ease-out, background-color 0.3s ease-out;
transition:border-color 0.3s ease-out, background-color 0.3s ease-out;
}
.btn:hover,
.btn:focus,
.btn:active { background-color:#AEB1B1;color:#333333;border-color:#AEB1B1;text-decoration:none;outline:0; }
.btn_success, a.btn_success { color:#FFFFFF;border-color:#64b92a;background-color:#64b92a; }
.btn_success:hover,
.btn_success:focus,
.btn_success:active { color:#FFFFFF;border-color: #50a118;background-color:#50a118; }
.btn_lg { padding:8px 14px;font-size:12pt; }
.btn_block { display:block;margin:0;padding:0;width:100%; }
.box_1 { border:1px solid #5C6666;margin:0; }
.box_1_body { background-color:#FFFFFF;border-top:1px solid #5C6666;margin:0;padding:6px; }
.box_1_title { background-color:#5C6666;color:#FFFFFF;margin:0;padding:6px;text-align:center; }
我的 HTML
<div class="body_1">
<div class="grid_1">
<div class="grid_1_left">
<div class="box_1">
<div class="box_1_title">Box 1</div>
<div class="box_1_body">
<a href="#" class="btn btn_success">Stays in the Box</a>
</div>
</div>
<br>
<div class="box_1">
<div class="box_1_title">Box 2</div>
<div class="box_1_body">
<a href="#" class="btn btn_success btn_block">Does NOT stay in the Box</a>
</div>
</div>
</div>
<div class="grid_1_right">
main body content
<br>
<a href="#" class="btn btn_success">Btn 1</a>
<a href="#" class="btn btn_success">Btn 2</a>
<br><br>
Note how the buttons can align without being stacked (ie: inline-block) must remain in .btn selector class
</div>
</div>
</div>