I have a group of images displayed on beneath the other, made to look as though they're one full image on first glance, but which break up on hover as the images shrink on hover.
Each of these images links to a different page on my website though, so I'd also like to add some text to the centre of each image on hover.
I've found lots of suggestions as to how to add the text, but none that don't break the image transition effect that I already have in place.
<style>
.image4 {
-webkit-transition: all 0.7s ease;
transition: all 0.7s ease;
}
.image4:hover {
-webkit-transform:scale(0.7);
transform:scale(0.7);
}
</style>
<a>
<A HREF="http://philandkaren.weebly.com/the-day.html">
<img class="image4" src="http://philandkaren.weebly.com/files/theme/Homepage1.jpeg">
</a>
<a>
<A HREF="http://philandkaren.weebly.com/getting-there.html">
<img class="image4" src="http://philandkaren.weebly.com/files/theme/Homepage2.jpeg">
</a>
<a>
<A HREF="http://philandkaren.weebly.com/local-information.html">
<img class="image4" src="http://philandkaren.weebly.com/files/theme/Homepage3.jpeg">
</a>
<a>
<A HREF="http://philandkaren.weebly.com/accommodation.html">
<img class="image4" src="http://philandkaren.weebly.com/files/theme/Homepage4.jpeg">
</a>
<a>
<A HREF="http://philandkaren.weebly.com/taxis.html">
<img class="image4" src="http://philandkaren.weebly.com/files/theme/Homepage5.jpeg">
</a>
<a>
<A HREF="http://philandkaren.weebly.com/honeymoon-fund.html">
<img class="image4" src="http://philandkaren.weebly.com/files/theme/Homepage6.jpeg">
</a>
<a>
<A HREF="http://philandkaren.weebly.com/faqs.html">
<img class="image4" src="http://philandkaren.weebly.com/files/theme/Homepage7.jpeg">
</a>
<a>
<A HREF="http://philandkaren.weebly.com/rsvp.html">
<img class="image4" src="http://philandkaren.weebly.com/files/theme/Homepage8.jpeg">
</a>
Does anyone know how I might achieve the text overlay that I'm looking for, whilst retaining the image scaling? Each image is 750 by 128.
Use the link as a wrapper, with position:relative and add your text content to an absolutely positioned overlay.
Then move the hover trigger to the parent link:
a:hover .image4 {
-webkit-transform: scale(0.7);
transform: scale(0.7);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.image4 {
-webkit-transition: all 0.7s ease;
transition: all 0.7s ease;
display: block;
}
a:hover .image4 {
-webkit-transform: scale(0.7);
transform: scale(0.7);
}
a {
margin: 1em;
display: inline-block;
position: relative;
text-decoration: none;
color: white;
}
a .overlay {
text-decoration: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
opacity: 0;
transition: opacity .7s ease;
}
a:hover .overlay {
opacity: 1;
}
<a HREF="http://philandkaren.weebly.com/faqs.html">
<img class="image4" src="http://philandkaren.weebly.com/files/theme/Homepage7.jpeg">
<div class="overlay">
<h1>OVERLAY TEXT</h1>
</div>
</a>
Related
Hello dear stack overflow citizens. I have a boring problem with two elements (watch code snippet below) but unfortunately, I ought to resolve it. I'll be grateful for any help or advice.
I need final result like this
In the circle with background: grey I positioned a relative social media links(.social__icon>img). I can’t load svg files from assets here. You can watch the screenshot with my embarrassing acts:
I don't have enough reputation to embed screenshots, I hope you can watch it somehow.
If not, it should look something like this:
social media link img margin left:12px socila media text-name also realative link img with hover and animation effects
They both needs to work like one in a row
Example
I'm facebook svg icon in the grey ellips 12px-left Facebook
Thats result with
.social__icon {
display: inline-flex; /* Changed */
align-items: center; /* Added */
enter image description here
Active mode:
enter image description here
ol,
ul,
li,
menu {
list-style: none;
}
a {
text-decoration: none;
}
.social__list {
display: flex;
flex-direction: column;
gap: 10px;
}
.social__icon {
display: inline-block;
text-align: center;
width: 26px;
height: 26px;
border-radius: 100%;
background: rgba(196, 196, 196, 0.5);
-webkit-transition: all 0.25s linear;
-moz-transition: all 0.25s linear;
-ms-transition: all 0.25s linear;
-o-transition: all 0.25s linear;
transition: all 0.25s linear;
}
.social__icon img {
vertical-align: middle;
}
.social__icon span {}
.social__icon:active {
background: #4B9200;
color: #4B9200;
}
.social__icon:hover {
animation: shake 500ms ease-in-out forwards;
}
#keyframes shake {
0% {
transform: rotate(2deg);
}
50% {
transform: rotate(-3deg);
}
70% {
transform: rotate(3deg);
}
100% {
transform: rotate(0deg);
}
}
<div class="social">
<ul class="social__list">
<li>
<a class="social__icon" href="https://en-gb.facebook.com" target="_blank" rel="noopener">
<img src="../../assets/icons/social/fb.svg" alt="">
<span>Facebook</span>
</a>
</li>
<li>
<a class="social__icon" href="https://twitter.com" target="_blank" rel="noopener">
<img src="../../assets/icons/social/twtr.svg" alt="">
<span>Twitter</span>
</a>
</li>
<li>
<a class="social__icon" href="https://www.instagram.com" target="_blank" rel="noopener">
<img src="../../assets/icons/social/inst.svg" alt="">
<span>Instagram</span>
</a>
</li>
<li>
<a class="social__icon" href="https://www.youtube.com" target="_blank" rel="noopener">
<img src="../../assets/icons/social/youtube.svg" alt="">
<span>Youtube</span>
</a>
</li>
</ul>
</div>
Some style issues in the image
ol,
ul,
li,
menu {
list-style: none;
}
a {
text-decoration: none;
}
.social__list {
display: flex;
flex-direction: column;
gap: 10px;
}
.social__icon {
display: inline-block;
text-align: center;
-webkit-transition: all 0.25s linear;
-moz-transition: all 0.25s linear;
-ms-transition: all 0.25s linear;
-o-transition: all 0.25s linear;
transition: all 0.25s linear;
}
.social__icon img {
width: 26px;
height: 26px;
vertical-align: middle;
border-radius: 100%;
background: rgba(196, 196, 196, 0.5);
}
.social__icon:active {
background: #4b9200;
color: #4b9200;
}
.social__icon:hover {
animation: shake 500ms ease-in-out forwards;
}
#keyframes shake {
0% {
transform: rotate(2deg);
}
50% {
transform: rotate(-3deg);
}
70% {
transform: rotate(3deg);
}
100% {
transform: rotate(0deg);
}
}
<div class="social">
<ul class="social__list">
<li>
<a
class="social__icon"
href="https://en-gb.facebook.com"
target="_blank"
rel="noopener"
>
<img
src="https://cdn3.iconfinder.com/data/icons/free-social-icons/67/facebook_circle_color-512.png"
alt=""
/>
<span>Facebook</span>
</a>
</li>
<li>
<a
class="social__icon"
href="https://twitter.com"
target="_blank"
rel="noopener"
>
<img
src="https://cdn4.iconfinder.com/data/icons/social-media-icons-the-circle-set/48/twitter_circle-512.png"
alt=""
/>
<span>Twitter</span>
</a>
</li>
<li>
<a
class="social__icon"
href="https://www.instagram.com"
target="_blank"
rel="noopener"
>
<img
src="https://cdn2.iconfinder.com/data/icons/social-media-applications/64/social_media_applications_3-instagram-512.png"
alt=""
/>
<span>Instagram</span>
</a>
</li>
<li>
<a
class="social__icon"
href="https://www.youtube.com"
target="_blank"
rel="noopener"
>
<img
src="https://cdn4.iconfinder.com/data/icons/logos-and-brands/512/395_Youtube_logo-512.png"
alt=""
/>
<span>Youtube</span>
</a>
</li>
</ul>
</div>
I'm kind of new to css and html, never touched JS or jquery.
I'm building as practice a website that looks like somewhat a portfolio site where I have some photos that are clickable. One thing that I wanted to do is, when a user hovers an image, an opaque box would pop up from the photo's bottom showing some text, the problem is that I want this text to be clickable as well so I put it inside the same anchor tag, but they don't overlap instead the clickable area stretches and the text gets positioned to the side of the image.
Is there a way of doing it so the "clickable area" doesn't stretch and the text overlap the image but without using the image as a background ?
Here's what I'm trying to achieve https://theme-frsch2.tumblr.com/ .
I've tried wrapping the text in a div and moving the text so it would overlap the image but the problem is that the "clickable" area would still be stretched anyway.
And this is what I got so far.
HTML
#allimg{
display: flex;
flex-wrap: wrap;
justify-content: center;
}
#allimg a{
margin: 10px;
border: 2px solid red;
}
#allimg img{
transition: 0.1s ease;
box-shadow: 5px 5px 10px #888888;
float: left;
border: 1px solid pink;
}
#allimg img:hover{
transform: scale(1.02);
}
#allimg a p{
color: black;
position: relative;
bottom: 20px;
left: 0;
text-align: center;
}
<div id="allimg">
<a href="link1">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text1
</p>
</a>
<a href="link2">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text2
</p>
</a>
<a href="link3">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text3
</p>
</a>
<a href="link4">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text4
</p>
</a>
</div>
Here is jsfiddel link
If you want to overlap text inside an image and achieve that hover effect on the website you attached
you have to use position: absolute for your text
and set the position for your anchor tag to relative
make it hideen by setting visibility property to hidden and opacity
to 0
then on anchor tag hover, you set it back visible and 1 opacity
#allimg{
display: flex;
flex-wrap: wrap;
justify-content: center;
}
#allimg a{
margin: 10px;
border: 2px solid red;
position: relative;
}
#allimg img{
transition: 0.1s ease;
box-shadow: 5px 5px 10px #888888;
float: left;
border: 1px solid pink;
}
#allimg img:hover{
transform: scale(1.02);
}
#allimg a p{
color: black;
position: absolute;
bottom: 0;
left: 0;
margin: 0;
text-align: center;
width: 100%;
padding: 10px 0;
background: rgba(255,255,255,.5);
visibility: hidden;
opacity: 0;
transition: .2s ease-in-out;
}
#allimg a:hover p{
visibility: visible;
opacity: 1
}
<div id="allimg">
<a href="link1">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text1
</p>
</a>
<a href="link2">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text2
</p>
</a>
<a href="link3">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text3
</p>
</a>
<a href="link4">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text4
</p>
</a>
</div>
Put the image in parent container and text in child container, then in css file add 'position:relative' to the parent container and add 'position:absolute' to the child container.
This will overlap text and image.
Somewhat like this:
HTML Part:
<div class="parent">
<img src="https://via.placeholder.com/150" alt="image">
<div class="child">
<p>Text goes here</p>
</div>
</div>
CSS Part:
.parent
{
position:relative;
text-align:center;
}
.child
{
position:absolute;
top:0px;
left:0px;
}
This will overlap text on image and you make changes as you want in the position of the text.
Here's my solution with smooth transition.
#allimg{
display: flex;
flex-wrap: wrap;
justify-content: center;
}
#allimg a{
position: relative;
margin: 10px;
border: 2px solid red;
box-sizing: border-box;
transition: all 0.3s ease;
}
#allimg img{
position: abosolute;
vertical-align: bottom;
transition: 0.1s ease;
box-shadow: 5px 5px 10px #888888;
border: 1px solid pink;
transition: all 0.3s ease;
}
#allimg img:hover{
transform: scale(1.02);
}
#allimg a p{
margin: 0;
padding: 5% 0;
width: 100%;
color: black;
background-color: #fff;
box-sizing: border-box;
position: absolute;
text-align: center;
bottom: 0;
left: 0;
opacity: 0;
transition: all 0.3s ease;
}
#allimg a:hover{
transform: scale(1.1);
transition: all 0.3s ease;
}
#allimg a:hover p{
opacity: 1;
transition: all 0.6s ease;
}
<div id="allimg">
<a href="link1">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text1
</p>
</a>
<a href="link2">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text2
</p>
</a>
<a href="link3">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text3
</p>
</a>
<a href="link4">
<img src="https://via.placeholder.com/150" alt="">
<p>
Text4
</p>
</a>
</div>
I don't know how to make text in the photo, and make a link in the whole photo. I've made a darkening effect which I don't want to change, I just want to add text to it. I really want to keep the current dimensions and, above all, responsiveness.
There is link to codepen: 'https://codepen.io/pawe-dejda/pen/XyPzpK'
body, html {
height: 100%;
}
.caption {
position: absolute;
left: 0;
top: 50%;
width: 100%;
text-align: center;
color: #000;
}
.responsive {
width: 100%;
max-width: 88px;
height: auto;
position: center;
}
.tz-gallery .row > div {
padding: 2px;
margin-bottom: 4px;
}
.tz-gallery .lightbox img {
width: 100%;
border-radius: 0;
position: relative;
}
#media(max-width: 768px) {
body {
padding: 0;
}
}
.fade {
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
.fade:hover {
opacity: 0.5;
}
<link rel="stylesheet" href="https://www.w3schools.com/w3css/3/w3.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="http://dejda.e-kei.pl/nuar/css/style.css">
<div class="w3-container w3-padding-64 w3-black">
<div class="w3-content">
<div class="tz-gallery">
<div class="row no-gutters">
<div class="col-sm-6 col-md-4">
<a class="lightbox fade" href="http://dejda.e-kei.pl/nuar/images/mieszkanie-w-kamienicy-lodz/mieszkanie-w-kamienicy-lodz5.jpg">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg">
</a>
</div>
<div class="col-sm-6 col-md-4">
<a class="lightbox fade" href="http://dejda.e-kei.pl/nuar/images/mieszkanie-w-kamienicy-lodz/mieszkanie-w-kamienicy-lodz5.jpg">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg">
</a>
</div>
<div class="col-sm-6 col-md-4">
<a class="lightbox fade" href="http://dejda.e-kei.pl/nuar/images/mieszkanie-w-kamienicy-lodz/mieszkanie-w-kamienicy-lodz5.jpg">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg">
</a>
</div>
</div>
</div>
</div>
</div>
If i understand correctly, you want to be able to post links (link can be a-href, h1, h2, span etc') on top of your picture. To do so, do the following:
1. write a container div. for example:
<div>
text
</div>
set its style (CSS) to the background picture you want. Make sure the div's sizes fit the picture size. Then, inside the div you can simply write down the tag you wish (text). for example:
< span >
text
< /span >
Now things get interesting. In order to position the text inside the div? => set the div's position to relative (position:relative;) and set the span position to absolute. then play around with the top / left / bottom / right of the absoloute position, and text would appear whereever you want it to.
Here's an updated codepen
https://codepen.io/kelvinsusername/pen/YROYZM
It adds a container with some text in it but makes it opaque, then on hover instead of making it less visible (like the image) it makes it more visible.
.fade:hover .description {
opacity: 1;
}
.description {
position: absolute;
z-index: 100;
opacity: 0;
color: #fff;
font-size: 20px;
}
.tz-gallery .row>div {
padding: 2px;
margin-bottom: 4px;
}
.tz-gallery .lightbox img {
width: 100%;
border-radius: 0;
position: relative;
}
.img-text-box {
position: absolute;
bottom: 0;
background: rgba(0, 0, 0, 0.479);
color: #ffffff;
width: 100%;
padding: 20px;
font-family: Arial;
font-size: 17px;
}
.fade {
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
color: #e9e9e9;
}
.fade:hover {
opacity: 0.5;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="tz-gallery">
<div class="container">
<div class="row">
<div class="col-md-4">
<a class="lightbox fade" href="">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg" alt="">
<div class="img-text-box">
<p>Be brave js is cool</p>
</div>
</a>
</div>
<div class="col-md-4">
<a class="lightbox fade" href="">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg" alt="">
<div class="img-text-box">
<p>Readability counts.</p>
</div>
</a>
</div>
<div class="col-md-4">
<a class="lightbox fade" href="">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg" alt="">
<div class="img-text-box">
<p>If the implementation is hard to explain, it's a bad idea.</p>
</div>
</a>
</div>
</div>
</div>
</div>
I am using isotope plugin for fluid grid and would like to add some effects for images on hover, in this the grid has 3 different images with different height: jsfiddle code. Is there some way to keep them responsive and fix heigh change on hover zoom? Please suggest, what has been done wrong?
HTML
<div class="item">
<a href="https://twitter.com/">
<img src="http://s9.postimg.org/n0sl7ucqn/image.jpg" alt="">
</a>
</div>
<div class="item">
<a href="https://twitter.com/">
<img src="http://s17.postimg.org/6r28okkq7/image.jpg" alt="">
</a>
</div>
<div class="item">
<a href="https://twitter.com/">
<img src="http://s17.postimg.org/c12m24flb/image.jpg" alt="">
</a>
</div>
CSS
.item {
width: 46.1%;
height: auto;
margin-right: 4%;
margin-bottom: 30px;
float: left;
overflow: hidden;
}
#social_indicator {
font-size: 14px;
font-weight: 300;
font-style: italic;
text-align: right;
margin-top: 0;
margin-bottom: 0;
}
.item img {
width: 100%;
height: 100%;
-webkit-transition: all 3s ease;
-moz-transition: all 3s ease;
-o-transition: all 3s ease;
-ms-transition: all 3s ease;
transition: all 3s ease;
}
.item img:hover {
width: 105%;
height: 105%;
margin-right: 1%;
margin-bottom: 1%;
}
}
First, the overflow:hidden; should be on the div, not the image.
I would set the height of the div with jQuery to prevent it from scaling, when the image does:
$('.item > a > img').each(function(index, value){
$(value).parent('a').parent('.item').height( $(value).height() );
});
Remember to add the jQuery-library in your <head>:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
I want my website to have the same effect this website has: Trask Industries
When the upper right image is hovered the text appears and yellow covers the image.
This is the effect I am failing to recreate in CSS and Html, using headers and hover opacity. In my attempts the headers become opaque rather than standing out like on that site. I also don't know how to make the headers appear and disappear on hover.
Here is the jsfiddle of my attempt.
.content1:hover, .content2:hover, .content3:hover, .content4:hover, .content5:hover, .content6:hover {
color: black;
opacity: 0.30;
transition: .2s;
webkit-transition: .2s;
-webkit-transition: all 500ms ease;
}
You must wrap the h1 and h2 in a div, and you would animate that div in css.
I also added a same class for the contents.
Here is an updated fiddle:
http://jsfiddle.net/bzm6T/2/
Basically, this is the updated code:
Code:
.contents:hover > div {
color: black;
opacity: 1;
}
.contents div {
opacity: 0;
display: block;
width: 100%; height: 100%;
background: rgba(255,255,255,0.3);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
<div class="container">
<a href="articleF.html" class="contents content1">
<div>
<h1>The Low Stakes of Modern life</h1>
<h2>Default 1Default 1Default 1Default 1Default 1Default 1</h2>
</div>
</a>
<a href="articleA1.html" class="contents content2">
<div>
<h1>AARON SWARTZ</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
<a href="articleA2.html" class="contents content3">
<div>
<h1>JOBILLY BOOP</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
<a href="articleD.html" class="contents content4">
<div>
<h1>Content4</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
<a href="articleK1.html" class="contents content5">
<div>
<h1>Content5</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
<a href="articleK1.html" class="contents Content6">
<div>
<h1>Content6</h1>
<h2>Cats Can Puuuuur</h2>
</div>
</a>
</div>
A slightly different approach, but basically the same with CSS transition: FIDDLE
.holder {
width: auto;
margin: 10px auto;
border: 1px solid black;
overflow: hidden;
}
.leftdiv {
float: left;
background-color: blue;
height: 100%;
color: white;
}
.picdiv {
float: right;
background-color: orange;
}
.picdiv img {
opacity: 1;
transition: opacity 1s ease-in-out;
}
.picdiv img:hover {
opacity: 0;
}