在我的页面上,我正在使用引导程序制作一个产品部分,通常我将每行放置 4 个产品,问题是当文本的名称较大时,div 会增长,但它旁边的 div 保持不变,我即使产品名称较大,也希望每行具有相同大小的 div。
HTML
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="estilo.cs.css">
</head>
<body>
<div class="container">
<row>
<div class="col-sm-6 col-md-3">
<div class="grid_1_4">
<div class="picture">
<img src="https://i.gyazo.com/4f1486b7c4384522db07c2d9090682f2.png" class="img-responsive center-block">
</div>
<h3>Samsung Galaxy S7 Edge </h3>
<div class="price_details">
<p><span class="money">2100 </span></p>
<p><button class="btn btn-default">Agregar al carrito</button></p>
</div>
</div>
</div>
<div class="col-sm-6 col-md-3">
<div class="grid_1_4">
<div class="picture">
<img src="https://i.gyazo.com/4f1486b7c4384522db07c2d9090682f2.png" class="img-responsive center-block">
</div>
<h3>Samsung Galaxy S7 Edge extra plus extra plus extra plus </h3>
<div class="price_details">
<p><span class="money">2100 </span></p>
<p><button class="btn btn-default">Agregar al carrito</button></p>
</div>
</div>
</div>
</row>
</div>
</body>
</html>
CSS
body{
margin-top: 20px;
}
.grid_1_4{
text-align: center;
border: 2px solid #EEE;
}
.picture{
height: 200px;
}
.picture img{
max-height: 100%;
max-width: 100%;
}
由于您使用的是 Bootstrap,因此您应该使用 Jquery,所以这里有一些可以帮助您的代码。
问候。