0

I have problem placing a button below a thumbnail in bootstrap. This image below shows three thumbnails with a button below it. The buttons are not vertically aligned because of the text that appears between the three different thumbnails and buttons are having different lengths. current display Here is my code:

<div class="col-md-3">
    <div class="thumbnail" style="height: 400px;">
        <img style="width: 200px; height: 200px;" src="<?php echo base_url();?>assets/user_file/product/<?php echo $row->foto; ?>">
        <div class="caption">
            <center>
                <h3><?php echo $row->nama_prod; ?></h3>
                <strong><p>Rp.<?php echo $row->harga; ?>.-</p></strong>
                <a href="<?php echo base_url()?>/index.php/pesanan/pesan?id_product=<?php echo $row->id_product?>" class="btn btn-success"> Pesan</a>
            </center>
        </div>
    </div>
</div>

How could I fix this?

naveen
  • 53,448
  • 46
  • 161
  • 251

3 Answers3

1

hope this may helpful:

make thumbnail class as relative position:relative; then add position:absolute; top:auto; bottom:0; to <a> tag

vishnu
  • 2,848
  • 3
  • 30
  • 55
1

Keep your image and caption in one row, and the link button in other row, like this:

<div class="col-md-3 text-center">
  <div class="thumbnail" style="height: 400px;">
    <div class="row">
      <img style="width: 200px; height: 200px;" src="<?php echo base_url();?>assets/user_file/product/<?php echo $row->foto; ?>">
      <div class="caption" style="height: 140px;">
          <h3><?php echo $row->nama_prod; ?></h3>
          <strong><p>Rp.<?php echo $row->harga; ?>.-</p></strong>
      </div>
    </div>
    <div class="row">
          <a href="<?php echo base_url()?>/index.php/pesanan/pesan?id_product=<?php echo $row->id_product?>" class="btn btn-success"> Pesan</a>
    </div>
  </div>
</div>

Set the "text-center" property to the alignment inside of the column. And the div class "caption" should have a height style.

Atoyansk
  • 233
  • 5
  • 20
0

One way will be to use two rows like this.

<div class="row">
    <div class="col-md-3">
        <div class="thumbnail" style="height: 400px;">
            <img style="width: 200px; height: 200px;" src="<?php echo base_url();?>assets/user_file/product/<?php echo $row->foto; ?>">
            <div class="caption">
                <center>
                    <h3><?php echo $row->nama_prod; ?></h3>
                    <strong><p>Rp.<?php echo $row->harga; ?>.-</p></strong>
                </center>
            </div>
        </div>
    </div>
    <div class="col-md-3">...</div>
    <div class="col-md-3">...</div>
</div>
<div class="row">
    <div class="col-md-3">
        <a href="<?php echo base_url()?>/index.php/pesanan/pesan?id_product=<?php echo $row->id_product?>" class="btn btn-success"> Pesan</a>
    </div>
    <div class="col-md-3">...</div>
    <div class="col-md-3">...</div>
</div>

P.S:center tag is deprecated. Do not use it. Why is the <center> tag deprecated in HTML?

Community
  • 1
  • 1
naveen
  • 53,448
  • 46
  • 161
  • 251