HTML CSS-arrange images (figure) with captions (figcaption) on the page?
I'm having a hard time putting the caption Inside My image, I want the caption to be at the bottom of the image(inside it), another thing is that my section.gallery is not inside my div#interface and I can't center it either.
@charset "UTF-8";
.postagem {
background-color: rgba(255,140,40,.05);
margin: 0px;
}
#interface {
width: 1200px;
background-color: white;
margin: 90px auto 10px auto;
box-shadow: 0px 4px 6px 3px rgba(0,0,0,.1);
}
.cabecalho {
transition: 0.2s;
top: 0px;
position: fixed;
width: 100%;
height: 35px;
background-color: rgba(255,140,40,1);
margin: 0px;
padding-bottom: 20px;
padding-top: 20px;
text-align: center;
}
.logo {
margin: 0px 0px 0px 0px;
color: rgba(255,255,255,1);
font-family: agency fb;
font-size: 20pt;
/*display: inline-block;*/
}
#fcor {
color: rgba(255,220,180,1);
}
.galeria {
margin-left: auto;
padding: 20px;
width: 1200px;
}
.legenda {
position: absolute;
text-align: center;
}
.imgp{
position: relative;
margin: 10px;
padding: 0px;
width: 200px;
height: 200px;
background-color: white;
box-shadow: 1px 1px 3px rgba(0,0,0,.4);
float: left;
}
/*Postagens*/
#postagem02 {
background-color: white;
background: url("../_imagens/win10.jpg") no-repeat;
background-size: 200px 200px;
}
#postagem03 {
background-color: white;
background: url("../_imagens/oracle.png") no-repeat;
background-size: 200px 200px;
}
#postagem05 {
background-color: white;
background: url("../_imagens/vnc.png") no-repeat;
background-size: 200px 200px;
}
#postagem04 {
background-color: white;
background: url("../_imagens/office.jpg") no-repeat;
background-size: 200px 200px;
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Processos e Manuais de Instruções</title>
<link rel="stylesheet" type="text/css" href="_css/estilo.css"/>
<link rel="stylesheet" type="text/css" href="_css/fotos.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).scroll(function() {
var y = $(this).scrollTop();
if (y < 25) {
$('.cabecalho').css({'padding-top': '20px','padding-bottom': '20px'});
} else {
$('.cabecalho').css({'padding-top': '5px', 'padding-bottom': '0px'});
}
});
</script>
</head>
<body class="postagem">
<header class="cabecalho">
<h1 class="logo">MANUAIS E PROCESSOS<span id="fcor"> INFORMÁTICA<span><h1/>
</header>
<div id="interface">
<section class="galeria">
<a href="_postagem/1009182.html"><figure><img class="imgp" src="https://image.ibb.co/cXVJ79/check.jpg"><figcaption class="legenda">Legenda Checklist</figcaption></figure></a>
<a href="_postagem/1009182.html"><figure><img class="imgp" src="https://image.ibb.co/gabEfU/win10.jpg"><figcaption class="legenda">Legenda Windows 10</figcaption><a href="_postagem/1009181.html"></a></figure>
<a href="_postagem/1009182.html"><figure><img class="imgp" src="https://image.ibb.co/eiiGup/oracle.png"><figcaption class="legenda">Legenda Oracle</figcaption><a href="_postagem/1009182.html"></a></figure>
<a href="_postagem/1009182.html"><figure><img class="imgp" src="https://image.ibb.co/deNLLU/office.png"><figcaption class="legenda">Legenda Office</figcaption><a href="_postagem/1009182.html"></a></figure>
<a href="_postagem/1009182.html"><figure><img class="imgp" src="https://image.ibb.co/cRLwup/vnc.png"><figcaption class="legenda">Legenda VNC</figcaption><a href="_postagem/1009182.html"></a></figure>
</section>
</div>
</body>
</html>
1
Author: Marcos Aurélio, 2018-09-13
1 answers
Guy your HTML structure had some problems, like a one tag <a>
inside another tag <a>
. This is not correct. Another problem is that vc uses float: left on some elements, so it was giving the impression that section.galeria
was not inside div#interface
. Also, some position
were in the wrong place...
I made some adjustments and now I think it was as you wanted. At a glance, display as "full page" to better see the result:
$(document).scroll(function () {
var y = $(this).scrollTop();
if (y < 25) {
$('.cabecalho').css({
'padding-top': '20px',
'padding-bottom': '20px'
});
} else {
$('.cabecalho').css({
'padding-top': '5px',
'padding-bottom': '0px'
});
}
});
@charset "UTF-8";
.postagem {
background-color: rgba(255, 140, 40, .05);
margin: 0px;
}
#interface {
width: 1200px;
background-color: white;
margin: 90px auto 10px auto;
box-shadow: 0px 4px 6px 3px rgba(0, 0, 0, .1);
}
#interface::after,
.galeria::after {
content: "";
display: table;
clear: both;
}
.cabecalho {
transition: 0.2s;
top: 0px;
position: fixed;
width: 100%;
height: 35px;
background-color: rgba(255, 140, 40, 1);
margin: 0px;
padding-bottom: 20px;
padding-top: 20px;
text-align: center;
}
.logo {
margin: 0px 0px 0px 0px;
color: rgba(255, 255, 255, 1);
font-family: agency fb;
font-size: 20pt;
/*display: inline-block;*/
}
#fcor {
color: rgba(255, 220, 180, 1);
}
.galeria {
display: flex;
justify-content: center;
}
.galeria a figure{
position: relative;
margin: 10px;
padding: 0px;
width: 200px;
height: 200px;
background-color: white;
box-shadow: 1px 1px 3px rgba(0, 0, 0, .4);
text-align: center;
}
.galeria a figure img{
width: 200px;
height: 200px;
}
.legenda {
position: absolute;
right: 0;
left: 0;
bottom: 10px;
margin: auto;
}
/*Postagens*/
#postagem02 {
background-color: white;
background: url("../_imagens/win10.jpg") no-repeat;
background-size: 200px 200px;
}
#postagem03 {
background-color: white;
background: url("../_imagens/oracle.png") no-repeat;
background-size: 200px 200px;
}
#postagem05 {
background-color: white;
background: url("../_imagens/vnc.png") no-repeat;
background-size: 200px 200px;
}
#postagem04 {
background-color: white;
background: url("../_imagens/office.jpg") no-repeat;
background-size: 200px 200px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body class="postagem">
<header class="cabecalho">
<h1 class="logo">MANUAIS E PROCESSOS<span id="fcor"> INFORMÁTICA</span>
</h1>
</header>
<div id="interface">
<section class="galeria">
<a href="_postagem/1009182.html">
<figure>
<img class="imgp" src="https://image.ibb.co/cXVJ79/check.jpg">
<figcaption class="legenda">Legenda Checklist</figcaption>
</figure>
</a>
<a href="_postagem/1009182.html">
<figure>
<img class="imgp" src="https://image.ibb.co/gabEfU/win10.jpg">
<figcaption class="legenda">Legenda Windows 10</figcaption>
</figure>
</a>
<a href="_postagem/1009182.html">
<figure><img class="imgp" src="https://image.ibb.co/eiiGup/oracle.png">
<figcaption class="legenda">Legenda Oracle</figcaption>
</figure>
</a>
<a href="_postagem/1009182.html">
<figure>
<img class="imgp" src="https://image.ibb.co/deNLLU/office.png">
<figcaption class="legenda">Legenda Office</figcaption>
</figure>
</a>
<a href="_postagem/1009182.html">
<figure>
<img class="imgp" src="https://image.ibb.co/cRLwup/vnc.png">
<figcaption class="legenda">Legenda VNC</figcaption>
</figure>
</a>
</section>
</div>
1
Author: hugocsl, 2018-09-13 15:19:42