Code: https://jsfiddle.net/z4udfg3o/
I want the divs "caixa" to be centered in the div "produtos". I was able to do it with exact values using margin-left. But I want it to be responsive for other screen sizes so I putted margin-left and margin-right as auto.
Image of desired format:
section {
padding: 2em 0;
display: flex;
justify-content: space-between;
background: antiquewhite;
}
section:before, section:after {
content: "";
}
div {
width: 10em;
height: 10em;
background: silver;
}
<section>
<div></div>
<div></div>
<div></div>
</section>
Use this CSS:
.produtos {
width: 100%;
background: gray;
margin-left: auto;
margin-right: auto;
display: inline-block;
}
.caixa {
width: 27.1%;
height: 250px;
background: darksalmon;
border: 1px solid #000;
float: left;
margin: 0 3%;
}
Like This?
.produtos {
width: 100%;
height: 252px;
background: gray;
text-align: center;
}
.caixa {
width: 250px;
height: 250px;
background: darksalmon;
border: 1px solid #000;
margin: 0 auto;
}
<div class="produtos">
<div class="caixa">
<img src="imagens/croa.png" style="margin-left:60px;">
<p style="text-align:center;">Temos os melhores produtos do mercado! Nossos competidores ajoelham-se perante a nossa qualidade!</p>
</div>
<div class="caixa">
<img src="imagens/dinheiro.png" style="margin-left:60px;">
<p style="text-align:center;">Preços mais baratos do mercado! Promoções 24/7! Se houver ofertas mais baratas diga e fazemos promoção de 0.01€!</p>
</div>
<div class="caixa">
<img href="#" src="imagens/definicoes.png" style="margin-left:60px;">
<p style="text-align:center;">Nosso departamento de apoio ao cliente está ativo 24/7! Resolveremos todas as suas dúvidas!</p>
</div>
</div>
Otherwise, i suggest you to have a look at flexbox
Do it like below:
#wrap {
background: #e7e7e7;
padding: 4px;
text-align: center;
width:100%;
}
#one, #two, #three {
background: #ccc;
display: inline-block;
padding: 20px;
width:20%;
}
<div id="wrap">
<div id="one">I am div 1</div>
<div id="two">I am div 2</div>
<div id="three">I am div 2</div>
</div>
try changing your css like below
.produtos
{
width: 100%;
height: 252px;
background: gray;
text-align: center;
}
.caixa
{
width: 250px;
height: 250px;
background: darksalmon;
border: 1px solid #000;
display: inline-block;
}
The following code sets the orange boxes as display: inline-block which causes them to follow the text flow, which is set to center in the parent container. This allows the boxes to flow depending on available screen space. On wide screens they're all side by side, on smaller ones they're arranged vertically.
I have also modified the HTML in order to get rid of newlines between the boxes. These newlines would cause margins otherwise.
.produtos
{
width: 100%;
background: gray;
text-align: center;
}
.caixa
{
vertical-align: top;
width: 250px;
height: 250px;
background: darksalmon;
border: 1px solid #000;
display: inline-block;
}
<div class="produtos">
<div class="caixa">
<img src="imagens/croa.png" style="margin-left:60px;">
<p style="text-align:center;">Temos os melhores produtos do mercado! Nossos competidores ajoelham-se perante a nossa qualidade!</p>
</div
><div class="caixa">
<img src="imagens/dinheiro.png" style="margin-left:60px;">
<p style="text-align:center;">Preços mais baratos do mercado! Promoções 24/7! Se houver ofertas mais baratas diga e fazemos promoção de 0.01€!</p>
</div
><div class="caixa">
<img href="#" src="imagens/definicoes.png" style="margin-left:60px;">
<p style="text-align:center;">Nosso departamento de apoio ao cliente está ativo 24/7! Resolveremos todas as suas dúvidas!</p>
</div>
</div>
I hope it works for you. I added each div class row for each to so you can set the padding in classemphasized text row.
.produtos
{
width: 100%;
height: 252px;
}
.caixa
{
width: 33%;
height: 100%;
background: darksalmon;
border:1px solid red;
float: left;
}
.row{
height:100%;
padding:0 20px;
}
<div class="produtos">
<div class="caixa">
<div class="row">
<img src="imagens/croa.png">
<p style="text-align:center;">Temos os melhores produtos do mercado! Nossos competidores ajoelham-se perante a nossa qualidade!</p>
</div>
</div>
<div class="caixa">
<div class="row">
<img src="imagens/dinheiro.png">
<p style="text-align:center;">Preços mais baratos do mercado! Promoções 24/7! Se houver ofertas mais baratas diga e fazemos promoção de 0.01€!</p>
</div> </div>
<div class="caixa">
<div class="row">
<img href="#" src="imagens/definicoes.png">
<p style="text-align:center;">Nosso departamento de apoio ao cliente está ativo 24/7! Resolveremos todas as suas dúvidas!</p>
</div> </div>
</div>
There are different ways, but if the boxes are to contain an image or something, then you will need a fixed aspect ratio, that can be accomplished like this:
.wrapper{float:left; width:100%; background-color:deeppink;}
.lil-box{float:left; width:22%; margin:0 5.665%; background-color:bisque;}
.tight-fit{float:left; width:100%; margin-top:100%;}
<div class="wrapper">
<div class="lil-box">
<div class="tight-fit"></div>
</div>
<div class="lil-box">
<div class="tight-fit"></div>
</div>
<div class="lil-box">
<div class="tight-fit"></div>
</div>
</div>
you should balance the width of both divs. "caixa" and "produtos".
I think using % will be responsive for other screeen size too.
Fiddle
Hope Fiddle link help you .
Related
I'm trying to fix when I shrink my website down to 768 pixels there seems to be too much whitespace on the left side, I am unable to work out where it is coming from and how I can fix it, I've tried to remove the default padding and margins, and changed the size of images, but that didn't seem to solve it. I will post some code. Any help would be appreciated.
{
margin: 0px;
padding: 0px;
}
div.item {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
position: relative;
left: 30%;
color: #f8d501;
}
img {
width: 100px;
height: 100px;
border: solid 5px #f8d501;
}
.caption {
/* Make the caption a block so it occupies its own line. */
display: block;
color: #f8d501;
}
div.item-1 {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
padding-top: 40px;
position: relative;
left: 30%;
color: yellow;
}
img {
max-width: 100%;
height: auto;
}
.caption-1 {
/* Make the caption a block so it occupies its own line. */
display: block;
color: #f8d501;
font-family: 'Verdana-bold';
}
h1 {
padding-top: 20px;
color: #fad700;
transform: rotate(-90deg);
font-size: 50px;
}
body {
background-color: #0d395e;
}
.logo-floatRight {
padding-left: 20px;
display: flex;
border: none;
max-width: 100%;
height: auto;
}
.logo-floatLeft {
padding-left: 20px;
display: inline-block;
border: none;
max-width: 100%;
height: auto;
padding: 10px;
}
.flex-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
padding-left: 35%;
max-width: 600px;
height: auto;
}
.logoHeader{
color: #f8d501;
font-family: "Franklin Gothic Heavy regular"
padding: 10px;
max-width: 100%;
height: auto;
}
.text{
color: #f8d501;
text-align: center;
padding-right: 30px;
}
.logo-floatLefts{
border: none;
width: 100%;
height: auto;
}
#media only screen and (max-width: 768px) {
img {
width: 60%;
}
.logoHeader{
font-size: 15px;
}
.flex-container{
width: 120px;
height: 120px;
}
.caption {
font-size: 12px;
}
.item {
font-size: 15px;
}
}
}
<div class="main">
<div class="showcase-content">
<div class="flex-container">
<img src="https://via.placeholder.com/150" class="logo-floatLeft" alt="logo">
<h2 class="logoHeader">LATIN<br>AMERICAN<br>FILM<br>FESTIVAL IN<br>AUSTRALIA</h2>
<img src="https://via.placeholder.com/150" class="logo-floatRight" alt="logo">
</div>
<div class="item">
BRAZIL
<img src="https://via.placeholder.com/150"/>
<span class="caption">LIFE IS A BITCH<br>Como e Cruel Viver Assim</span>
</div>
<div class="item">
CHILE
<img src="https://via.placeholder.com/150"/>
<span class="caption">BROKEN PANTIES<br>Colzones Ratos</span>
</div>
<div class="item">
COLOMBIA
<img src="https://via.placeholder.com/150"/>
<span class="caption">BAD LUCKY GOAT<br>El Dia De La Cabra</span>
</div>
<div class="item">
COSTA RICA
<img src="https://via.placeholder.com/150"/>
<span class="caption">THE GAZELLE'S DANCE<br>El Baile La Gacela </span>
</div>
<div class="item">
CUBA
<img src="https://via.placeholder.com/150"/>
<span class="caption">FALLEN GODS<br>Los Dioses Rotos</span>
</div>
<br>
<div class="item-1">
ECUADOR
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">QUIJOTES NEGROS<br>Quijotes Negros</span>
</div>
<div class="item-1">
EL SALVADOR
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE PATH OF THE SHADOWS<br>El Camino De Las Sombras</span>
</div>
<div class="item-1">
GAUTEMALA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">WHERE ALL ROADS END<br>Donde Acaban Los Caminos.</span>
</div>
<div class="item-1">
MEXICO
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">MARA'AKAME'S DREAM<br>El Sueno Del Mara'akame</span>
</div>
<div class="item-1">
PANAMA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">GRACE & SPLENDOUR<br>Donaire Y Esplendo</span>
</div>
<br>
<div class="item-1">
<h1> FREE<br>EVENT </h1>
</div>
<div class="item-1">
PARAGUAY
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE HEIRESSES<br>Las Herederas</span>
</div>
<div class="item-1">
PERU
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">OLD FRIENDS<br>Viejos Amigos</span>
</div>
<div class="item-1">
URUGUAY
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE POPES TOILET<br>El Bano Del Papa.</span>
</div>
<div class="item-1">
ARGENTINA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">MAN FANCING SOUTHEAST<br>Hombre Mirando al Sudeste</span>
</div>
<div class="text">
<h3>FIND OUT WHEN FESTIVAL IS COMING TO YOUR CITY AT<br>WWW.FACEBOOK.COM/LAFFAUSSIE</h3>
<img src="footer.png" class="logo-floatLefts" alt="logo">
</div>
</div>
</div>
I just removed your extra margin and padding both from the item,item-1, flex-container class, and add only vertical-align and text-align center. And there is no extra margin or padding on the left. all the content remains in the center. Hope it will solve your problem. I also removed img and flex-container class from the media queries.
{
margin: 0px;
padding: 0px;
}
div.item {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
position: relative;
color: #f8d501;
}
img {
width: 100px;
height: 100px;
border: solid 5px #f8d501;
}
.caption {
/* Make the caption a block so it occupies its own line. */
display: block;
color: #f8d501;
}
div.item-1 {
/* To correctly align image, regardless of content height: */
vertical-align: top;
display: inline-block;
/* To horizontally center images and caption */
text-align: center;
/* The width of the container also implies margin around the images. */
width: 120px;
padding-top: 40px;
position: relative;
color: yellow;
}
img {
max-width: 100%;
height: auto;
}
.caption-1 {
/* Make the caption a block so it occupies its own line. */
display: block;
color: #f8d501;
font-family: 'Verdana-bold';
}
h1 {
padding-top: 20px;
color: #fad700;
transform: rotate(-90deg);
font-size: 50px;
}
body {
background-color: #0d395e;
}
.logo-floatRight {
border: none;
max-width: 100%;
height: auto;
padding: 10px;
}
.logo-floatLeft {
border: none;
max-width: 100%;
height: auto;
padding: 10px;
}
.center-text {
text-align: center;
}
.flex-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
justify-content: center;
}
.logoHeader{
color: #f8d501;
font-family: "Franklin Gothic Heavy regular"
padding: 10px;
max-width: 100%;
height: auto;
}
.text{
color: #f8d501;
text-align: center;
padding-right: 30px;
}
.logo-floatLefts{
border: none;
width: 100%;
height: auto;
}
#media only screen and (max-width: 768px) {
.logoHeader{
font-size: 15px;
}
.caption {
font-size: 12px;
}
.item {
font-size: 15px;
}
}
<div class="main">
<div class="showcase-content">
<div class="flex-container">
<img src="https://via.placeholder.com/150" class="logo-floatLeft" alt="logo">
<h2 class="logoHeader">LATIN<br>AMERICAN<br>FILM<br>FESTIVAL IN<br>AUSTRALIA</h2>
<img src="https://via.placeholder.com/150" class="logo-floatRight" alt="logo">
</div>
<div class="center-text">
<div class="item">
BRAZIL
<img src="https://via.placeholder.com/150"/>
<span class="caption">LIFE IS A BITCH<br>Como e Cruel Viver Assim</span>
</div>
<div class="item">
CHILE
<img src="https://via.placeholder.com/150"/>
<span class="caption">BROKEN PANTIES<br>Colzones Ratos</span>
</div>
<div class="item">
COLOMBIA
<img src="https://via.placeholder.com/150"/>
<span class="caption">BAD LUCKY GOAT<br>El Dia De La Cabra</span>
</div>
<div class="item">
COSTA RICA
<img src="https://via.placeholder.com/150"/>
<span class="caption">THE GAZELLE'S DANCE<br>El Baile La Gacela </span>
</div>
<div class="item">
CUBA
<img src="https://via.placeholder.com/150"/>
<span class="caption">FALLEN GODS<br>Los Dioses Rotos</span>
</div>
</div>
<br>
<div class="center-text">
<div class="item-1">
ECUADOR
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">QUIJOTES NEGROS<br>Quijotes Negros</span>
</div>
<div class="item-1">
EL SALVADOR
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE PATH OF THE SHADOWS<br>El Camino De Las Sombras</span>
</div>
<div class="item-1">
GAUTEMALA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">WHERE ALL ROADS END<br>Donde Acaban Los Caminos.</span>
</div>
<div class="item-1">
MEXICO
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">MARA'AKAME'S DREAM<br>El Sueno Del Mara'akame</span>
</div>
<div class="item-1">
PANAMA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">GRACE & SPLENDOUR<br>Donaire Y Esplendo</span>
</div>
</div>
<br>
<div class="center-text">
<div class="item-1">
<h1> FREE<br>EVENT </h1>
</div>
<div class="item-1">
PARAGUAY
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE HEIRESSES<br>Las Herederas</span>
</div>
<div class="item-1">
PERU
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">OLD FRIENDS<br>Viejos Amigos</span>
</div>
<div class="item-1">
URUGUAY
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">THE POPES TOILET<br>El Bano Del Papa.</span>
</div>
<div class="item-1">
ARGENTINA
<img src="https://via.placeholder.com/150"/>
<span class="caption-1">MAN FANCING SOUTHEAST<br>Hombre Mirando al Sudeste</span>
</div>
</div>
<div class="text">
<h3>FIND OUT WHEN FESTIVAL IS COMING TO YOUR CITY AT<br>WWW.FACEBOOK.COM/LAFFAUSSIE</h3>
<img src="footer.png" class="logo-floatLefts" alt="logo">
</div>
</div>
</div>
The padding:0 and margin:0 in the start are for body, which I think you have forgot to write.
If that doesn't solve, check each section by commenting to see which section is bigger in width to leave the white spaces.
I am trying to make a restaurant menu but I can't figure out how to do it I want to make the div named "menu-spacer" the maximum size it could get.
With the "min-width" and "max-width" it only takes the minimum width.
Render screenshot:
<div class="wrapper container w-50">
<div class="wrapper menu block">
<div class="menu-content">Un menu tout à fait normal</div>
<div class="menu-spacer"></div>
</div>
<div class="price block">50€</div>
</div>
<div class="wrapper container w-50">
<div class="wrapper menu block">
<div class="menu-content">Un menu</div>
<div class="menu-spacer"></div>
</div>
<div class="price block">50€</div>
</div>
.wrapper {
display: flex;
}
.menu-content{
width: ;
}
.menu-spacer{
width: max-content;
border-bottom: green 2px dotted;
}
.menu {
width: 80%;
text-align: left;
color: black;
padding-bottom: 0px;
}
.price {
width: min-content;
text-align: right;
color: black;
}
I think the secret here is knowing about vw and vh as you can research here:
Viewport units: vw, vh, vmin, vmax
See the fiddle: JSFiddle
.wrapper {
display: flex;
}
.menu-content {
width: ;
}
.menu-spacer {
width: 100vw;
border-bottom: green 2px dotted;
}
.menu {
width: 80%;
text-align: left;
color: black;
padding-bottom: 0px;
}
.price {
width: min-content;
text-align: right;
color: black;
}
<div class="wrapper container w-50">
<div class="wrapper menu block">
<div class="menu-content">Un menu tout à fait normal</div>
<div class="menu-spacer"></div>
</div>
<div class="price block">50€</div>
</div>
<div class="wrapper container w-50">
<div class="wrapper menu block">
<div class="menu-content">Un menu</div>
<div class="menu-spacer"></div>
</div>
<div class="price block">50€</div>
</div>
I'm trying to draw a dotted line between some of my elements without success; I'm trying to accomplish something like the following:
I've looked at a few tutorials to write a line between the elements using the ::after pseudo-element, but I don't see anything happening.
.container {
width: 1066px;
margin: 0 auto;
}
.services {
text-align: center;
max-width: 1080px;
padding: 80px 0;
position: relative;
}
.services .step {
display: inline-block;
width: 152px;
height: 100px;
margin: 50px;
vertical-align: text-top;
}
.services .step .first {
float: right;
}
.services .icons {
background: url("https://www.icracked.com/themes/icracked/images/steps-line.png") repeat-x;
}
<div class="services container">
<div class="step first">
<strong>PASO 1</strong>
<br>
<p>Pon el codigo postal donde te encuentres</p>
</div>
<div class="step">
<strong>PASO 2</strong>
<br>
<p>Dinos qual es el problema</p>
</div>
<div class="step">
<STRONG>PASO 3</STRONG>
<br>
<p>Relajate, nuestro tecnico esta de camino</p>
</div>
<div class="step last">
<STRONG>PASO 4</STRONG>
<br>
<p>Voilà! En menos de una hora tienes el movil arreglado!</p>
</div>
<div class="icons">
<div class="step first">
<img src="http://via.placeholder.com/50x50" alt="" height="50" width="50"></div>
<div class="step">
<img src="http://via.placeholder.com/50x50" alt="" height="50" width="50"></div>
<div class="step">
<img src="http://via.placeholder.com/50x50" alt="" height="50" width="50"></div>
<div class="step last">
<img src="http://via.placeholder.com/50x50" alt="" height="50" width="50"></div>
</div>
</div>
http://jsfiddle.net/zhpmahnq/187/
You could try using display: flex; and creating a dotted border on only the top or bottom of a span between images.
.wrapper {
align-items: center;
display: flex;
justify-content: space-between; /* not necessary */
}
.dots {
border-top: 1px dotted black;
width: 100%;
}
https://jsfiddle.net/zhpmahnq/191/
I have a problem with Pure CSS Mansonry layout. I use position: relative for the boxes and position: absolute for the content inside each box. However, I noticed that when I use position: absolute, there's an gap under each box. I couldn't figure out how to fix it. You can also check it out at this codepen: http://codepen.io/kikibres/pen/KWjXeG
HTML
#import "compass/css3";
*, *:before, *:after {box-sizing: border-box !important;}
.servicogallery {
-moz-column-gap: 0;
-webkit-column-gap: 0;
-moz-column-count: 3;-webkit-column-count: 3;column-count: 3;
position: relative;
display: block;
width: 100%;
}
#services {
display: inline-block;
margin: 0;
padding: 1rem;
width: 100%;
height: 250px;
position: relative;
}
#services span {
position: absolute;
bottom: 0;
left: 0;
padding: 20px;
vertical-align: bottom;
}
.a1 {
background-color: #0026e7;
color: #FFF;
}
.a2 {
background-color:/*#189ed8*/#ffffff;
color: /*#FFF*/#998b75;
}
.a3 {
background-color:/*#fff*/#bac0b8;
color: /*#998b75*/#ffffff;
}
.a4 { background-color: #646664;
color: #FFF;
}
.a5 {background-color: #0026e7;
color: #FFF;
}
.a6 {background-color: #29a1e6;
color: #FFF;
}
.a7 {background-color: #fff;
color: #998b75;
}
.a8 {background-color: #bac0b8;
color: #FFF;
}
.a9 { background-color: #fff;
color: #998b75;
}
.a10 { background-color: #0029e5;
color: #FFF;
}
.a11 { background-color: #5e605e;
color: #FFF;
}
/* styles for background color, etc; not necessary for this thing to work */
body {
padding: 1em;
font-family: "Garamond", serif;
}
h1 {
font-size: 3rem;
font-weight: 800;
}
body {
line-height: 1.25;
}
p {
text-align: left;
}
<h1>Pure CSS Masonry</h1>
<p>By using CSS3 columns, we can easily create a Masonry.js-like layout where random-height blocks fit together.</p>
<div class="servicogallery">
<div id="services" class="a1">
<span>
<p>Formulación y Evaluación de Proyectos de Construcción.</p></span>
</div>
<div id="services" class="a2">
<span>
<p>Mantenimiento Varios (Edificaciones, Calles, entre otros).</p></span>
</div>
<div id="services" class="a3">
<span>
<p>Diseño: Arquitectónico, Habitacional, Industrial, Urbano y Comercial.</p></span>
</div>
<div id="services" class="a4">
<span>
<p>Taludes, Muros.</p></span>
</div>
<div id="services" class="a5">
<span>
<p>Supervisión de Proyectos</p></span>
</div>
<div id="services" class="a6">
<span>
<p>Estudios de Factibilidad Técnica – Económica de proyectos de construcción.</p></span>
</div>
<div id="services" class="a7">
<span>
<p>Diseño Integral de Obras de Ingeniería y Arquitectura.</p></span>
</div>
<div id="services" class="a8">
<span>
<p>Tramitología.</p></span>
</div>
<div id="services" class="a9">
<span>
<p>Obras de Mitigación</p></span>
</div>
<div id="services" class="a10">
<span>
<p><strong>Construcción de Obras Civiles y Remodelaciones:</strong></p>
<p>Centros comerciales, urbanizaciones, infraestructura: Hidráulica y Víal, complejos industriales, turísticos, deportivo, centros decapacitación, vivienda, centros educativo, hospitales, taludes, muros, obras de mitigación</p>
<p>Aplicación de pintura con maquinaria industrial avanzada, entre otros.</p></span>
</div>
<div id="services" class="a11">
<span>
<p>Uso de equipo para la realización de pruebas no destructivas en concreto.</p></span>
</div>
</div>
What I'm trying to achieve is no gaps around the boxes as well the content to be at bottom of each box. All I could tell is that the position: absolute is affecting the gaps.
Add vertical-align: top; to #services
#import "compass/css3";
*, *:before, *:after {box-sizing: border-box !important;}
.servicogallery {
-moz-column-gap: 0;
-webkit-column-gap: 0;
-moz-column-count: 3;-webkit-column-count: 3;column-count: 3;
position: relative;
display: block;
width: 100%;
}
#services {
margin: 0;
padding: 1rem;
width: 100%;
height: 250px;
position: relative;
vertical-align: top;
display: inline-block;
}
#services span {
position: absolute;
bottom: 0;
left: 0;
padding: 20px;
vertical-align: bottom;
}
.a1 {
background-color: #0026e7;
color: #FFF;
}
.a2 {
background-color:/*#189ed8*/#ffffff;
color: /*#FFF*/#998b75;
}
.a3 {
background-color:/*#fff*/#bac0b8;
color: /*#998b75*/#ffffff;
}
.a4 { background-color: #646664;
color: #FFF;
}
.a5 {background-color: #0026e7;
color: #FFF;
}
.a6 {background-color: #29a1e6;
color: #FFF;
}
.a7 {background-color: #fff;
color: #998b75;
}
.a8 {background-color: #bac0b8;
color: #FFF;
}
.a9 { background-color: #fff;
color: #998b75;
}
.a10 { background-color: #0029e5;
color: #FFF;
}
.a11 { background-color: #5e605e;
color: #FFF;
}
/* styles for background color, etc; not necessary for this thing to work */
body {
padding: 1em;
font-family: "Garamond", serif;
}
h1 {
font-size: 3rem;
font-weight: 800;
}
body {
line-height: 1.25;
}
p {
text-align: left;
}
<h1>Pure CSS Masonry</h1>
<p>By using CSS3 columns, we can easily create a Masonry.js-like layout where random-height blocks fit together.</p>
<div class="servicogallery">
<div id="services" class="a1">
<span>
<p>Formulación y Evaluación de Proyectos de Construcción.</p></span>
</div>
<div id="services" class="a2">
<span>
<p>Mantenimiento Varios (Edificaciones, Calles, entre otros).</p></span>
</div>
<div id="services" class="a3">
<span>
<p>Diseño: Arquitectónico, Habitacional, Industrial, Urbano y Comercial.</p></span>
</div>
<div id="services" class="a4">
<span>
<p>Taludes, Muros.</p></span>
</div>
<div id="services" class="a5">
<span>
<p>Supervisión de Proyectos</p></span>
</div>
<div id="services" class="a6">
<span>
<p>Estudios de Factibilidad Técnica – Económica de proyectos de construcción.</p></span>
</div>
<div id="services" class="a7">
<span>
<p>Diseño Integral de Obras de Ingeniería y Arquitectura.</p></span>
</div>
<div id="services" class="a8">
<span>
<p>Tramitología.</p></span>
</div>
<div id="services" class="a9">
<span>
<p>Obras de Mitigación</p></span>
</div>
<div id="services" class="a10">
<span>
<p><strong>Construcción de Obras Civiles y Remodelaciones:</strong></p>
<p>Centros comerciales, urbanizaciones, infraestructura: Hidráulica y Víal, complejos industriales, turísticos, deportivo, centros decapacitación, vivienda, centros educativo, hospitales, taludes, muros, obras de mitigación</p>
<p>Aplicación de pintura con maquinaria industrial avanzada, entre otros.</p></span>
</div>
<div id="services" class="a11">
<span>
<p>Uso de equipo para la realización de pruebas no destructivas en concreto.</p></span>
</div>
</div>
I'm building a 3x3 grid of thumbnails. A 'hover' effect makes the thumbnails grow. But the other images in the gallery move out or under the one that is growing. How can I fix it?
If there's a CSS solution, that would be great. Otherwise, I'm open to using jQuery.
.galeria {
margin-top: 15px;
width: 400px;
height: 520px;
border: 3px solid black;
border-radius: 15px;
}
#vis2 {
text-align: center;
}
.imgs {
display: inline-block;
margin-left: 20px;
}
.despliegue {
width: 95px;
height: 95px;
border: 3px dashed yellow;
border-radius: 100%;
padding: 10px 10px 10px 10px;
align-items: center;
margin-top: 15px;
position: sticky;
}
.despliegue:hover {
width: 140px;
height: 140px;
position: static;
}
.pieimg {
display: none;
}
.despliegue:hover + .pieimg {
display: block;
font-style: normal;
position: absolute;
}
<div class="galeria">
<h4 id="vis2">Dale un vistazo a las notas relevantes</h4>
<div class="imgs">
<img class="despliegue" src="images/aurora.jpg">
<p class="pieimg">Aurora gana premio !en Europa¡</p>
<img class="despliegue" src="images/bio.jpg">
<p class="pieimg">Bioshock se posiciona</p>
<img class="despliegue" src="images/amazon.jpg">
<p class="pieimg">Amazon, vuelve a dar de que hablar</p>
</div>
<div class="imgs">
<img class="despliegue" src="images/guerra.png">
<p class="pieimg">Microsoft, Android y Apple ¿Quien lleva cabeza?</p>
<img class="despliegue" src="images/windows.png">
<p class="pieimg">Windows 10. Te damos consejos</p>
<img class="despliegue" src="images/carlos.jpg">
<p class="pieimg">Carlos Sadness dice que podría venir a LATAM para 2015</p>
</div>
<div class="imgs">
<img class="despliegue" src="images/las_ventajas.jpg">
<p class="pieimg">Nota de: Película</p>
<img class="despliegue" src="images/mcw.png">
<p class="pieimg">Microsoft ataca con nueva <b>Surface</b>
</p>
<img class="despliegue" src="images/netflix.png">
<p class="pieimg">El éxito detras de tan famosa plataforma</p>
</div>
</div>
View on CodePen
It's spilling on to the next line because the container div is not big enough to hold the new larger img along with the other two.
By increasing the width on .galeria to something like 450px, it eliminates this issue.
Add width: 450px; to .galeria, adjust the width until it looks right. :)
.galeria {
margin-top: 15px;
width: 450px;
height: 520px;
border: 3px solid black;
border-radius: 15px;
}
#vis2 {
text-align: center;
}
.imgs {
display: inline-block;
margin-left: 20px;
}
.despliegue {
width: 95px;
height: 95px;
border: 3px dashed yellow;
border-radius: 100%;
padding: 10px 10px 10px 10px;
align-items: center;
margin-top: 15px;
position: sticky;
}
.despliegue:hover {
width: 140px;
height: 140px;
position: static;
}
.pieimg {
display: none;
}
.despliegue:hover + .pieimg {
display: block;
font-style: normal;
position: absolute;
}
<div class="galeria">
<h4 id="vis2">Dale un vistazo a las notas relevantes</h4>
<div class="imgs">
<img class="despliegue" src="images/aurora.jpg">
<p class="pieimg">Aurora gana premio !en Europa¡</p>
<img class="despliegue" src="images/bio.jpg">
<p class="pieimg">Bioshock se posiciona</p>
<img class="despliegue" src="images/amazon.jpg">
<p class="pieimg">Amazon, vuelve a dar de que hablar</p>
</div>
<div class="imgs">
<img class="despliegue" src="images/guerra.png">
<p class="pieimg">Microsoft, Android y Apple ¿Quien lleva cabeza?</p>
<img class="despliegue" src="images/windows.png">
<p class="pieimg">Windows 10. Te damos consejos</p>
<img class="despliegue" src="images/carlos.jpg">
<p class="pieimg">Carlos Sadness dice que podría venir a LATAM para 2015</p>
</div>
<div class="imgs">
<img class="despliegue" src="images/las_ventajas.jpg">
<p class="pieimg">Nota de: Película</p>
<img class="despliegue" src="images/mcw.png">
<p class="pieimg">Microsoft ataca con nueva <b>Surface</b>
</p>
<img class="despliegue" src="images/netflix.png">
<p class="pieimg">El éxito detras de tan famosa plataforma</p>
</div>
</div>