I needed to make some adjustments to your CSS, but I did not move in HTML.
I've left everything commented on in CSS.
Black overlay does not go over the parent element, as I'm using the CSS function calc()
to discount margins and paddins from other classes that was influencing this. (I also put a class in the img{}
face that all images will occupy the total space of the Thumbnail and not over white space)
OBS: Important. Bootstrap changes some Paddins and Margins to some class depending on screen size. So it's accurate add this @media to the black overlay to work fine on all screens. (@dvd tip in another response)
@media screen and (min-width: 768px) {
.hover{
/* calcula o tamanho total menos as margins e padding dos elementos pai */
height: calc(100% - 30px);
}
}
Run Snippet on "All Page" to see right since it has <div class="col-md-4 col-sm-4">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" />
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<style>
.hover{
position: absolute;
margin: 0px;
padding: 0px;
/* calcula o tamanho total menos as margins e padding dos elementos pai */
height: calc(100% - 10px);
width: calc(100% - 40px);
box-sizing: border-box;
transition: all 0.25s linear;
}
.hover:hover{
background-color: rgba(0, 0, 0, 0.5);
}
/* para alinhar btn no centro do tumbnail */
.legenda{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.btn-legenda{
font-family: 'Roboto', sans-serif;
color: white;
background-color: rgb(0, 0, 0);
letter-spacing: 2px;
padding: 10px;
font-size: 1.2em;
border: 0.5px solid white;
transition: all 0.4s linear;
}
.btn-legenda:hover{
background-color: white;
color: black;
}
/* para deixar a img em 100% do tumbnail */
img {
min-width: 100%;
height: auto;
}
/* nas tela maiores tem um ajuste de padding na classe e vc precisa corrigir a altura */
@media screen and (min-width: 768px) {
.hover{
/* calcula o tamanho total menos as margins e padding dos elementos pai */
height: calc(100% - 30px);
}
}
</style>
</head>
<body>
<div class="col-md-4 col-sm-4">
<div class="thumbnail">
<div class="hover">
<div class="legenda">
<button class="btn-legenda">Ver este Projeto</button>
</div>
</div>
<img src="http://placecage.com/300/400"/></div></div><divclass="col-md-4 col-sm-4">
<div class="thumbnail">
<div class="hover">
<div class="legenda">
<button class="btn-legenda">Ver este Projeto</button>
</div>
</div>
<img src="http://placecage.com/300/200"/></div></div><scriptsrc="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>