Reputation: 4049
I'm using Bootstrap component, and facing some issues with aligning thumbnail components, due to text, that have various size.
My target is to have a sort of control panel, that display difference access, depending on user right (sometime 3 blocks are displayed, sometimes 10 blocks)
Here is the code.
<!DOCTYPE html>
<html lang="fr">
<head>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.2/css/font-awesome.min.css">
<link rel="stylesheet" href="/stylesheets/template.css">
<script type="text/javascript" src="/bootstrap/js/bootstrap-filestyle.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/bootstrap/js/bootstrap.min.js" charset="utf-8"> </script>
<script type="text/javascript">
var height = 0;
$(".col-md-4").each(function(){
if (height < $(".col-md-4").outerHeight())
height = $(".col-md-4").outerHeight();
});
$(".col-md-4").height(height);
</script>
</head>
<body>
<div class="container">
<div style="text-align:center;" class="row">
<div class="col-sm-6 col-md-4">
<div class="thumbnail"><img src="/images/fonctionnalites/degustations_300x200.jpg" alt="..." class="img-thumbnail">
<div class="caption">
<h3>Dégustations</h3>
<p>Retrouvez les dernieres dégustations de votre reseau.</p>
<p><a href="" class="btn btn-success btn-block">Afficher</a></p>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail"><img src="/images/fonctionnalites/Vins_300x200.jpg" alt="..." class="img-thumbnail">
<div class="caption">
<h3>Vins</h3>
<p>Retrouvez tous les vins de la base et leurs étiquettes</p>
<p><a href="" class="btn btn-success btn-block">Afficher</a></p>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail"><img src="/images/fonctionnalites/vignerons_300x200.jpg" alt="..." class="img-thumbnail">
<div class="caption">
<h3>Vignerons</h3>
<p>Rencontrez les Vignerons français et leurs terroirs !</p>
<p><a href="" class="btn btn-success btn-block">Afficher</a></p>
</div>
</div>
</div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail"><img src="/images/fonctionnalites/cavistes_300x200.jpg" alt="..." class="img-thumbnail">
<div class="caption">
<h3>Cavistes</h3>
<p>Rencontrez les Cavistes français proches de vous !</p>
<p><a href="" class="btn btn-success btn-block">Afficher </a></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Here some screenshot depending on the screen size :
The 4th block is switched to right, due to different block height.
The when i resize the screen, and that all block text required 2 lines, their height become the same, and the world is perfect like this.
Question : how force this behavior in every screen configuration.
With the CSS (the standard one):
body {
padding-top: 0px;
padding-bottom: 75px;
word-wrap:break-word;
}
.starter-template {
padding: 40px 15px;
text-align: center;
}
.bs-docs-example
{
position: relative;
margin: 15px 0;
padding: 39px 19px 14px;
background-color: white;
border: 1px solid #DDD;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
.bs-docs-example::after
{
content: "Example";
position: absolute;
Upvotes: 0
Views: 292
Reputation: 167192
This is a real problem when comes to Masonry style tiles. You can do it using JavaScript this way:
var height = 0;
$(".col-md-4").each(function(){
if (height < $(".col-md-4").outerHeight())
height = $(".col-md-4").outerHeight();
});
$(".col-md-4").height(height);
Upvotes: 1