I am trying to build a page that has a paragraph of text with 4 images in a quad that are directly to the right of it. The problem is I've previously tried using floats, but as expected, this did not work and so far I have this... http://www.franhaines.co.uk/paddlethewye/
The code:
#panel1 {
padding: 5%;
width: 100%;
background-color: #16818a;
}
#intro-text {
background-color: #16818a;
width: 50%;
}
div#quad {
background-color: #111; font-size: 0;
width: 50%; margin: 0 auto;
}
div#quad figure {
margin: 0; width: 50%; height: auto;
transition: 1s; display: inline-block;
position: relative;
}
div#quad figure img {
width: 100%;
height: auto;
}
div#quad figure:nth-child(1) {
transform-origin: top left;
}
div#quad figure:nth-child(2) {
transform-origin: top right;
}
div#quad figure:nth-child(3) {
transform-origin: bottom left;
}
div#quad figure:nth-child(4) {
transform-origin: bottom right;
}
.expanded {
transform: scale(2);
z-index: 5;
}
div.full figure:not(.expanded) {
pointer-events: none;
}
div#quad figure:hover {
cursor: pointer;
z-index: 4;
}
<section id="panel1">
<div id='intro-text'>
<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ac dui enim.</h3>
</div>
<div id="quad">
<figure>
<img src="http://www.franhaines.co.uk/paddlethewye/wp-content/uploads/2015/02/courses.jpg" alt="courses" width="1000" height="700" class="alignnone size-full wp-image-31" />
</figure>
<figure>
<img src="http://www.franhaines.co.uk/paddlethewye/wp-content/uploads/2015/02/rental.jpg" alt="rental" width="1000" height="700" class="alignnone size-full wp-image-32" />
</figure>
<figure>
<img src="http://www.franhaines.co.uk/paddlethewye/wp-content/uploads/2015/02/tour.jpg" alt="tour" width="1000" height="700" class="alignnone size-full wp-image-33" />
</figure>
<figure>
<img src="http://www.franhaines.co.uk/paddlethewye/wp-content/uploads/2015/02/where.jpg" alt="where" width="2592" height="1944" class="alignnone size-full wp-image-34" />
</figure>
</div>
</section>
Any help would be appreciated, cheers!
You can use display:table & table-cell to layout the wrapping divs and float the images.
#panel1 {
display: table;
width: 100%;
table-layout:fixed; /* split columns equally */
}
#intro-text {
display: table-cell;
vertical-align: middle;
}
#quad {
display: table-cell;
vertical-align: middle;
}
#quad img {
display: block;
width: 50%;
height: auto;
float: left;
}
<section id="panel1">
<div id='intro-text'>
<h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ac dui enim.</h3>
</div>
<div id="quad">
<figure>
<img src="http://www.franhaines.co.uk/paddlethewye/wp-content/uploads/2015/02/courses.jpg" alt="courses" class="alignnone size-full wp-image-31" />
</figure>
<figure>
<img src="http://www.franhaines.co.uk/paddlethewye/wp-content/uploads/2015/02/rental.jpg" alt="rental" class="alignnone size-full wp-image-32" />
</figure>
<figure>
<img src="http://www.franhaines.co.uk/paddlethewye/wp-content/uploads/2015/02/tour.jpg" alt="tour" class="alignnone size-full wp-image-33" />
</figure>
<figure>
<img src="http://www.franhaines.co.uk/paddlethewye/wp-content/uploads/2015/02/where.jpg" alt="where" class="alignnone size-full wp-image-34" />
</figure>
</div>
</section>
Ideally the images should be the same size.
http://jsfiddle.net/fncjqonn/1/. Float #intro-text and div#squad left. Then width: 50%; on div#squad figure
#panel1 {
padding: 5%;
width: 100%;
background-color: #16818a;
overflow: hidden;
}
#intro-text {
background-color: #16818a;
width: 50%;
float: left;
}
div#quad {
background-color: #111;
font-size: 0;
width: 50%;
margin: 0 auto;
float: left;
}
div#quad figure {
margin: 0;
width: 50%;
height: auto;
transition: 1s;
display: inline-block;
position: relative;
}
Related
I have a task that supports older browsers such as IE9, so I cannot use flexbox or CSS Grid.
I'm struggling with making the .second and .third have equal height as the .first div.
Here is my attempt.
https://codepen.io/abccba_123/pen/QWKMwpK
img {
width: 100%;
height: auto;
}
.first img {
background-color: gold;
}
.second img {
background-color: cyan;
}
.third img {
background-color: grey;
}
.container {
width: 1000px;
margin: 0 auto;
}
.container article {
position: relative;
}
.wrap {
position: absolute;
bottom: 0;
}
.first {
float: left;
width: 50%;
}
.second {
float: left;
width: 30%;
}
.third {
float: left;
width: 30%;
}
<div class="container">
<article class="first">
<img width="1920" height="1080">
<div class="wrap">
<h3>Lorem ipsum dolor sit amet.<h3>
</div>
</article>
<article class="second">
<img width="1920" height="1080">
<div class="wrap">
<h3>Lorem ipsum dolor sit amet.<h3>
</div>
</article>
<article class="third">
<img width="1920" height="1080">
<div class="wrap">
<h3>Lorem ipsum dolor sit amet.<h3>
</div>
</article>
</div>
What I want.
Thank you!!
You may also use a display:table reset ;) Understood by every browsers and IE8+
(.wrap div removed , but you can use it)
img {
width: 100%;
height: auto;
}
.first {
background-color: gold;
}
.second {
background-color: cyan;
margin-bottom: 5px;
}
.third {
background-color: grey;
}
.container {
width: 100%;/* for demo */
/* width:1000px; */
margin: 0 auto;
display: table;
/* IE8 + */
table-layout: fixed;
/* IE8 + */
border-spacing: 5px;
border: solid;
}
.container article {
border: solid;
margin: -left:5px;
}
h3 {
padding: 1em;
}
.img {
vertical-align: top;
}
.first {
display: table-cell;
/* IE8 + */
width: 50%;
vertical-align: top;
}
<div class="container">
<article class="first">
<img src="https://picsum.photos/id/118/536/354.jpg" width="1920" height="1080">
<h3>Lorem ipsum dolor sit amet. </h3>
</article>
<article class="second">
<img src="https://picsum.photos/id/1015/536/354.jpg" width="1920" height="1080">
<h3>Lorem ipsum dolor sit amet. </h3>
</article>
<article class="third">
<img src="https://picsum.photos/id/1016/536/354.jpg" width="1920" height="1080">
<h3>Lorem ipsum dolor sit amet. </h3>
</article>
</div>
A simple table layout:
img {
display:block;
}
.first img {
background-color: gold;
}
.second img {
background-color: cyan;
}
.third img {
background-color: grey;
}
.container {
margin: 0 auto;
}
.container td {
position: relative;
}
.container td h3 {
position:absolute;
bottom:0;
left:0;
right:0;
}
<table class="container">
<tr>
<td class="first" rowspan="2">
<img width="300" height="400">
<h3>Lorem ipsum dolor sit amet.</h3>
</td>
<td class="second">
<img width="300" height="200">
<h3>Lorem ipsum dolor sit amet.</h3>
</td>
</tr>
<tr>
<td class="third">
<img width="300" height="200">
<h3>Lorem ipsum dolor sit amet.</h3>
</td>
</tr>
</table>
.cont {
width: 1000px;
margin: 0 auto;
}
img {
width: 100%;
height: 100%;
}
article {
position: relative;
}
.first {
float: left;
width: 500px;
height: 300px;
background-color: gold;
}
.second, .third {
float: left;
width: 500px;
height: 150px;
overflow: hidden;
}
.second {
background-color: lime;
}
.third {
background-color: cyan;
}
.info {
color: white;
padding: 10px 10px 0 10px;
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
<div class="cont">
<article class="first">
<img src="https://picsum.photos/1920/1080" width="1920" height="1080">
<div class="info">
<h3>Lorem ipsum dolor sit amet.</h3>
</div>
</article>
<article class="second">
<img src="https://picsum.photos/1920/1080" width="1920" height="1080">
<div class="info">
<h3>Lorem ipsum dolor sit amet.</h3>
</div>
</article>
<article class="third">
<img src="https://picsum.photos/1920/1080" width="1920" height="1080">
<div class="info">
<h3>Lorem ipsum dolor sit amet.</h3>
</div>
</article>
</div>
I've partially solved my own problem.
How to make the green images occupy the whole territory of each rectangle?
i use this code but there is a mistake somewhere:
.grid {
position: relative;
margin: 0 auto;
padding: 1em 0 4em;
max-width: 1000px;
list-style: none;
text-align: center;
}
.grid h2 {
color: #fefbfd !important;
background-color: transparent;
text-transform: none;
font-weight: normal;
text-align: left;
font-size: 26pt;
}
.grid figure {
position: relative;
float: left;
overflow: hidden;
margin: 10px 1%;
width: 500px;
height: 330px;
width: 48%;
background: #575656; /*REMOVES GREY SQUARES*/
text-align: center;
cursor: pointer;
}
.grid figure img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
opacity: 1;
}
.grid figure figcaption {
padding: 2em;
color: #575656;
text-transform: none;
font-size: 1.25em;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.grid figure figcaption::before,
.grid figure figcaption::after {
pointer-events: none;
}
.grid figure figcaption,
.grid figure figcaption > a {
position: absolute;
top: -30px;
left: -20px;
width: 100%;
height: 100%;
}
.grid figure figcaption > a {
z-index: 1000;
text-indent: 200%;
white-space: nowrap;
font-size: 0;
opacity: 0;
}
.grid figure figcaption h2 {
color: #a32914;
word-spacing: 0em;
font-weight: 300;
}
.grid figure h2 span {
font-weight: 800;
}
.grid figure h2,
.grid figure p {
margin: 0;
}
.grid figure p {
letter-spacing: 0px;
margin: 0;
font-size: 12pt;
}
ul li .MathJax_Display {
text-align: center;
margin: 1em 0em;
position: relative;
/*display: block !important;*/
display: inline !important;
text-indent: 0;
max-width: none;
max-height: none;
min-width: 0;
min-height: 0;
width: 100%;
}
[![SCREENSHOT BELOW][1]][1]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head><meta name="generator" content="olat-tinymce-4" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title></head><body><div class="container">
<link rel="stylesheet" type="text/css"
href="css/style.css">
<div class="grid">
<figure class="effect1"><img src="pic1.png" caption="false" width="500" height="333" />
<figcaption>
<h2><strong>Participants<br /></strong></h2>
View more</figcaption>
<figcaption></figcaption>
<figcaption></figcaption>
</figure>
<figure class="effect1"><img src="pic2.png" caption="false" width="500" height="333" />
<figcaption>
<h2><strong>Organisation</strong></h2>
View more</figcaption>
</figure>
<figure class="effect-artem"><img src="pic3.png" caption="false" width="500" height="333" />
<figcaption>
<h2><strong>Library</strong></h2>
View more</figcaption>
</figure>
<figure class="effect-artem"><img src="pic4.png" caption="false" width="500" height="333" />
<figcaption>
<h2><strong>Working Groups</strong></h2>
View more</figcaption>
</figure>
</div>
</div></body></html>
those were HTML code and CSS code
screenshot of what comes out of there below:
screenshot of what comes out of there:
[1]: https://i.stack.imgur.com/VjQCa.jpg
Check this, It may solve your problem. Try to run this below script
.grid figure {
position: relative;
float: left;
overflow: hidden;
margin: 10px 1%;
width: 500px;
height: 330px;
width: 48%;
background: #575656; /*REMOVES GREY SQUARES*/
text-align: center;
cursor: pointer;
}
.grid figure img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
opacity: 1;
}
.grid figure figcaption {
padding: 2em;
color: #575656;
text-transform: none;
font-size: 1.25em;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
<div class="grid">
<figure class="effect1">
<a href="javascript:parent.gotonode(102071756014162)">
<img src="https://wallpaperaccess.com/full/1288076.jpg" caption="false"/></a>
<figcaption>
<h2>
<strong>Participants<br/></strong>
</h2>
View more
</figcaption>
<figcaption></figcaption>
<figcaption></figcaption>
</figure>
<figure class="effect1"><img src="https://abduzeedo.com/sites/default/files/styles/square_1x1/public/originals/abdz_infrared_arashiyama_mockup_0.jpg?itok=D_-Tf7rE" caption="false"/>
<figcaption>
<h2>
<strong>Organisation</strong>
</h2>
View more
</figcaption>
</figure>
</div>
Try this code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="olat-tinymce-4" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
.grid figure {
position: relative;
float: left;
overflow: hidden;
margin: 10px 1%;
width: 500px;
height: 330px;
width: 48%;
background: #575656; /*REMOVES GREY SQUARES*/
text-align: center;
cursor: pointer;
}
.grid figure img {
width: 100%;
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
opacity: 1;
}
.grid figure figcaption {
padding: 2em;
color: #575656;
text-transform: none;
font-size: 1.25em;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
</style>
</head>
<body>
<div class="container">
<link rel="stylesheet" type="text/css" href="css/style.css">
<div class="grid">
<figure class="effect1">
<a href="javascript:parent.gotonode(102071756014162)">
<img src="red.png" caption="false" width="500" height="333" />
</a>
<figcaption>
<h2><strong>Participants<br /></strong></h2>
View more
</figcaption>
<figcaption></figcaption>
<figcaption></figcaption>
</figure>
<figure class="effect1">
<img src="pic2.png" caption="false" width="500" height="333" />
<figcaption>
<h2><strong>Organisation</strong></h2>
View more
</figcaption>
</figure>
<figure class="effect-artem">
<img src="pic3.png" caption="false" width="500" height="333" />
<figcaption>
<h2><strong>Library</strong></h2>
View more
</figcaption>
</figure>
<figure class="effect-artem">
<img src="pic4.png" caption="false" width="500" height="333" />
<figcaption>
<h2><strong>Working Groups</strong></h2>
View more
</figcaption>
</figure>
</div>
</div>
</body>
</html>
I have added width property.
Here is the result:
the problem was in images themselves! they were almost 1 Mb size png with alpha channel. when i just cut them with paint and saved with lower resolution -it has worked out
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
I am trying to make a gallery, the links show up from the bottom on
hover. I am having trouble regarding hiding them when they are not on hover.
.imageWrapper {
position: relative;
width: 200px;
height: 200px;
display: inline-block;
padding: 0px;
margin: 0px;
}
.imageWrapper img {
display: block;
width: 200px;
height: 200px;
padding: 0px;
margin: 0px;
}
.imageWrapper .cornerLink {
height:100px;
width:200px;
opacity: 0.7;
position: absolute;
bottom: 0px;
left: 0px;
margin: 0;
padding: 0;
color: #ffffff;
background-color: cadetblue;
text-decoration: none;
text-align: center;
transform: translateX(0) translateY(100px) translateZ(0);
transition-duration:0.3s;
transition-property: transform;
}
.imageWrapper:hover .cornerLink {
transform: translateX(0) translateY(0) translateZ(0);
}
a{
color: #ffffff;
text-decoration: none;
text-align: center;
}
<body>
<main>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
</main>
</body>
Add overflow:hidden; to your .imageWrapper class. Here's working code:
.imageWrapper {
position: relative;
width: 200px;
height: 200px;
display: inline-block;
padding: 0px;
margin: 0px;
overflow:hidden;
}
.imageWrapper img {
display: block;
width: 200px;
height: 200px;
padding: 0px;
margin: 0px;
}
.imageWrapper .cornerLink {
height:100px;
width:200px;
opacity: 0.7;
position: absolute;
bottom: 0px;
left: 0px;
margin: 0;
padding: 0;
color: #ffffff;
background-color: cadetblue;
text-decoration: none;
text-align: center;
transform: translateX(0) translateY(100px) translateZ(0);
transition-duration:0.3s;
transition-property: transform;
}
.imageWrapper:hover .cornerLink {
transform: translateX(0) translateY(0) translateZ(0);
}
a{
color: #ffffff;
text-decoration: none;
text-align: center;
}
<body>
<main>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
</main>
</body>
Change this line transform: translateX(0) translateY(100px) translateZ(0); to transform: translateX(0) translateY(115px) translateZ(0);:
Add overflow:hidden to .imageWrapper to remove the space under images
.imageWrapper {
position: relative;
width: 200px;
height: 200px;
display: inline-block;
padding: 0px;
margin: 0px;
overflow: hidden; /* Hides links when off image */
}
.imageWrapper img {
display: block;
width: 200px;
height: 200px;
padding: 0px;
margin: 0px;
}
.imageWrapper .cornerLink {
height: 100px;
width: 200px;
opacity: 0.7;
position: absolute;
bottom: 0px;
left: 0px;
margin: 0;
padding: 0;
color: #ffffff;
background-color: cadetblue;
text-decoration: none;
text-align: center;
transform: translateX(0) translateY(100px) translateZ(0);
transition-duration: 0.3s;
transition-property: transform;
}
.imageWrapper:hover .cornerLink {
transform: translateX(0) translateY(0) translateZ(0);
}
a {
color: #ffffff;
text-decoration: none;
text-align: center;
}
<body>
<main>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
<div class="imageWrapper">
<img src="http://placehold.it/200x200" alt="" />
<div class="cornerLink">
Link
</div>
</div>
</main>
</body>
I am trying to make a grid where the images have an overlay on hover, containing text.
However, I can't seem to do this AND have responsive issues.
I've tried removing the fixed heights but this just causes the grids to loose their sizing all together. I have tried tables and absolute positioning without any joy.
Test site is here.
The markup is:
<div class="work-item clickable">
<div class="front">
<img width="460" height="380" src="http://localhost:8888/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
</div>
<div class="back">
<div class="inner">
<h3>Lorem ipsum dolor sit amet</h3>
</div>
</div>
</div>
CSS:
section#homepage .content article .work-item {
cursor: pointer;
border-right: 20px solid #fff;
border-bottom: 20px solid #fff;
float: left;
overflow: hidden;
position: relative;
width: 33.33%;
}
section#homepage .content article .work-item .front {
color: #fff;
width: 100%;
z-index: 50;
opacity: 1;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
section#homepage .content article .work-item .back {
display: table;
width: 100%;
opacity: 0;
z-index: 25;
position: absolute;
}
section#homepage .content article .work-item .back .inner {
display: table-cell;
padding: 20px;
vertical-align: middle;
}
Here is an example layout, based on your example, which includes overlapping text on hover of an image.
The <figure> element seems good for this. It needs an image and a <figcaption>. Let's wrap it in an anchor tag so the entire image is clickable:
<a>
<figure>
<img />
<figcaption></figcaption>
</figure>
</a>
The CSS
The anchor element can line up the images. The width is 33.33% so that there are 3 images to a row. The images can be spaced with some padding here as well:
a {
display: inline-block;
width: 33.33%;
vertical-align: top;
padding: 10px;
}
The figure is made position: relative so that the position: absolute figcaption is positioned relative to it. This will ensure that the text is layered over the image. We can center it vertically with top: 50% and the transform to offset it correctly:
figure {
position: relative;
}
figcaption {
position: absolute;
text-align: center;
top: 50%;
right: 0;
left: 0;
transform: translateY(-50%);
}
The image takes up the entire width of its parent:
figure img {
width: 100%;
display: block;
}
Full example
*,
*:before,
*:after {
margin: 0;
padding: 0;
box-sizing: inherit;
}
html {
box-sizing: border-box;
}
body {
min-width: 600px;
}
a {
display: inline-block;
width: 33.33%;
vertical-align: top;
padding: 10px;
}
figure {
position: relative;
transition: opacity .2s;
}
figure:before {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, 0.4);
content: '';
opacity: 0;
transition: inherit;
}
figcaption {
position: absolute;
text-align: center;
top: 50%;
right: 0;
left: 0;
transform: translateY(-50%);
opacity: 0;
transition: inherit;
}
figcaption h2 {
font-size: 3vw;
}
figcaption p {
font-size: 2vw;
}
a {
color: #FFF;
text-decoration: none;
}
figure img {
width: 100%;
display: block;
}
figure:hover:before,
figure:hover figcaption {
opacity: 1;
}
<a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h2>Lorem ipsum dolor sit amet</h2>
<p>More text here, plenty of space</p>
</figcaption>
</figure>
</a><a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h2>Lorem ipsum dolor sit amet</h2>
<p>More text here, plenty of space</p>
</figcaption>
</figure>
</a><a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h2>Lorem ipsum dolor sit amet</h2>
<p>More text here, plenty of space</p>
</figcaption>
</figure>
</a><a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h2>Lorem ipsum dolor sit amet</h2>
<p>More text here, plenty of space</p>
</figcaption>
</figure>
</a><a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h2>Lorem ipsum dolor sit amet</h2>
<p>More text here, plenty of space</p>
</figcaption>
</figure>
</a><a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h2>Lorem ipsum dolor sit amet</h2>
<p>More text here, plenty of space</p>
</figcaption>
</figure>
</a>
Text size: The text can be made to re-size to suit the image width using vw as a font-size.
Image size: Place a min width on the body so that the images don't get too small.
Overlay background: This is provided with the figure:before element.
Note: The <a> elements have no whitespace between them, this prevents an inline gap. The box-sizing: border-box incorporates padding and borders into the width and height calculation.
maybe you could rethink your html structure about links and images, and play with absolute positionning for either image or title.
example:
body {
text-align: center;
}
.work-item {
display: inline-block;
vertical-align: top;
width: 25%;
margin: 1em;
}
a {
display: inline-table;
border: solid;
width: 100%;
color: black;
text-decoration: none;
}
figure {
position: relative;
display: table-row;
}
figure img {
width: 100%;
height: 100%;
top: 0;
position: absolute;
transition: 0.5s
}
figcaption:before {
content: '';
display: inline-block;
vertical-align: middle;
width: 0;
padding-top: 92%;
}
figcaption {
display: table-cell;
}
figure:hover img {
opacity: 0;
}
figcaption h3 {
display: inline-block;
max-width: 98%;
margin: 0 -2%;
vertical-align: middle;
}
<div class="work-item clickable">
<a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img width="460" height="380" src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h3>Lorem ipsum dolor sit amet</h3>
</figcaption>
</figure>
</a>
</div>
<div class="work-item clickable">
<a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h3>Lorem ipsum dolor sit amet</h3>
</figcaption>
</figure>
</a>
</div>
<div class="work-item clickable">
<a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img width="460" height="380" src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h3>Lorem ipsum dolor sit amet</h3>
</figcaption>
</figure>
</a>
</div>
<div class="work-item clickable">
<a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img width="460" height="380" src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h3>Lorem ipsum dolor sit amet</h3>
</figcaption>
</figure>
</a>
</div>
</div>
<div class="work-item clickable">
<a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h3>Lorem ipsum dolor sit amet</h3>
</figcaption>
</figure>
</a>
</div>
<div class="work-item clickable">
<a href="http://dev.charlyanderson.co.uk/Testing/work-example-client-name-12/">
<figure>
<img width="460" height="380" src="http://dev.charlyanderson.co.uk/Testing/wp-content/uploads/2016/02/stock-photo-4772348-1500x1000-460x380.jpg" class="attachment-work-featured-image size-work-featured-image" alt="stock-photo-4772348-1500x1000" />
<figcaption>
<h3>Lorem ipsum dolor sit amet</h3>
</figcaption>
</figure>
</a>
</div>
Hope this works for you!
jsfiddle
HTML
<a href="#" class="outer">
<div class="inner"><img src="http://farm9.staticflickr.com/8311/8023199579_f52f648727_m.jpg"></div>
<div class="overlay">Text</div>
</a>
<a href="#" class="outer">
<div class="inner"><img src="http://farm9.staticflickr.com/8311/8023199579_f52f648727_m.jpg"></div>
<div class="overlay">Text</div>
</a>
<a href="#" class="outer">
<div class="inner"><img src="http://farm9.staticflickr.com/8311/8023199579_f52f648727_m.jpg"></div>
<div class="overlay">Text</div>
</a>
CSS
.outer {
width: 33.333%;
overflow: auto;
float: left;
position: relative;
}
.outer .inner {
display: block;
margin: 10px;
}
.outer .inner img {
width: 100%;
height: auto;
border: 0px;
display: block;
}
.outer .overlay {
position: absolute;
top: 0;
opacity: 0;
width:100%;
height:100%;
background-color:pink;
-webkit-transition: opacity .15s ease-in-out;
-moz-transition: opacity .15s ease-in-out;
-ms-transition: opacity .15s ease-in-out;
-o-transition: opacity .15s ease-in-out;
transition: opacity .15s ease-in-out;
}
.outer:hover .overlay {
opacity: 0.7;
}
Your outer would be of coarse your article tag
I have a gallery on my site, but when I add figcaption it all goes wrong and each picture becomes central. What have I done incorrectly? I really can not imagine how to improve it.
#image{
position: inherit;
width:300px;
-webkit-transition:all 1s;
transition:all 1s;
margin-top:10px;
}
#image:hover{
position: inherit;
-webkit-transform:scale(3);
transform:scale(3);
margin: 0 auto;
highslide: auto;
}
figure.img img {
max-width: 300px;
height: auto;
}
figure.img figcaption {
padding: 5px;
font: bold italic 90% Georgia,serif;
color: #17432e;
width: 300px;
margin-left: 0px;
}
.pictures {
margin: 100px auto;
width: 980px;
}
.clear {
clear: both;
}
Then in body I have after all changes according to your advice
<div align="center">
<figure class="img">
<img id="image" src="pics/1.jpg" class="passe-partout">
<figcaption>In the village</figcaption>
</figure>
<figure class="img">
<img id="image" src="pics/2.jpg" class="passe-partout">
<figcaption>August</figcaption>
</figure>
<figure class="img">
<img id="image" src="pics/3.jpg" class="passe-partout">
<figcaption>The bridge</figcaption>
</figure>
<figure class="img">
<img id="image" src="pics/4.jpg" class="passe-partout">
<figcaption>A cute house</figcaption>
</figure>
<div class="clear"></div>
</div>
Here is the working solution.
---CSS Code--
figure img{
position: inherit;
width:300px;
-webkit-transition:all 1s;
transition:all 1s;
margin-top:10px;
}
figure img:hover{
position: inherit;
-webkit-transform:scale(3);
transform:scale(3);
margin: 0 auto;
highslide: auto;
}
figure> figcaption {
padding: 5px;
font: bold italic 90% Georgia,serif;
color: #17432e;
width: 300px;
margin-left: 0px;
}
/----HTML Code -----/
<div align=center class="pictures">
<figure class="img">
<img id="image" src="http://lorempixel.com/200/200" class="passe-partout">
<figcaption>In the village</figcaption>
</figure>
<figure class="img">
<img id="image" src="http://lorempixel.com/200/200" class="passe-partout">
<figcaption>In the village</figcaption>
</figure>
<figure class="img">
<img id="image" src="http://lorempixel.com/200/200" class="passe-partout">
<figcaption>In the village</figcaption>
</figure>
</div>
Here is a Working Demo. http://jsbin.com/musovipo/1/
I've made the code more valid by removing the multiple identical id's
and wrapping each img/figcaption pair with a figure element. To show the figures on same line, display: inline-block was added to the figure elements
CSS
div.img img {
width: 300px;
max-width: 300px;
height: auto;
position: inherit;
-webkit-transition: all 1s;
transition: all 1s;
margin-top: 10px;
}
div.img img:hover {
position: inherit;
-webkit-transform: scale(3);
transform: scale(3);
margin: 0 auto;
highslide: auto;
}
div.img figcaption {
padding: 5px;
font: bold italic 90% Georgia,serif;
color: #17432e;
width: 300px;
margin-left: 0px;
}
div.img figure {
display: inline-block;
}
HTML
<div class="img">
<div align=center class="pictures">
<figure>
<img src="pics/1.jpg" class="passe-partout">
<figcaption>In the village</figcaption>
</figure>
<figure>
<img src="pics/2.jpg" class="passe-partout">
<figcaption>August</figcaption>
</figure>
<figure>
<img src="pics/3.jpg" class="passe-partout">
<figcaption>The bridge</figcaption>
</figure>
<figure>
<img src="pics/4.jpg" class="passe-partout">
<figcaption>A cute house</figcaption>
</figure>
<div class="clear"></div>
</div>
</div>