如何对齐div底部的按钮?

时间:2012-05-13 20:03:13

标签: jquery html css

我有一个名为block_inside的div。在其中,text_block_button中有两个div,text_block和text_block_button.Button类,使用jquery.text_block显示和隐藏类(段落),text_block_button div是内联的。当我单击按钮时,div展开并显示“about”class.While显示和隐藏类,如何将按钮类对齐block_inside div的底部。这是html代码:

<div class="block_inside">
  <div class="text_block">                   
    <p>Here is paragraph.  </p>
    <p class="about">Here is hidden paragraph.(more than 500 words.) </p>
  </div>
  <div class="text_block_button">
     <a class="button">About</a>
  </div>
</div>

这是css代码:

.block_inside {
   display:block;
   border:1px solid #FFFFFF;
   overflow:auto;
   padding-left: 10px;
}
.text_block {
   float:left;
   width:600px;
   margin-left:30px;
   padding: 0px;
}
.text_block_button {
   float: right;
   padding-right: 15px;
   padding-bottom: 5px;
   padding-left: 5px;
}
a.button {
   padding:5px 10px 5px 10px;
   color: #ffffff;
   text-decoration: none;
   border:1px solid #32312f;
   text-transform:uppercase;
   font-size:9px;
   line-height:25px;    
}

这是jquery代码:

<script>
$(document).ready(function() {
$('p.about').hide();    
$('a.button').click(function() {
    $('p.about').toggle();
});

});
</script>

1 个答案:

答案 0 :(得分:3)

demo jsBin

.block_inside {
    position:relative; /*added*/
    /* ... */
}

.text_block_button {
    position:absolute;    /*added*/
    bottom:10px;          /*added*/
    right:10px;           /*added*/
    /* ... */
}