I would like to change the opacity of the img and add a 50x50 thumbnail for zoom on hover using only CSS no jquery. This is what I have done so far.
HTML code:
<div class="span4">
<a class="zoom-icon" href="#">
<img class="blackout image-1" alt="Elite Sports" src="http://www.domain.com/images/es.jpg" width="300" height="300">
</a>
</div>
CSS code:
.span4 { margin: 35px 50px; border: 5px solid #000; }
.span4:hover { border: 5px solid #ccc; }
.span4 a:hover { background: #000; }
.blackout:hover { opacity: .0; }
I have the black background on hover working but I can't figure out how to make the thumbnail show up over top of the black background "blackout". Any helpful tips would be much appreciated.
UPDATE w/Fiddle:
http://jsfiddle.net/8BMYH/
Something like this
http://jsfiddle.net/8BMYH/14/
HTML
<div class="span4"> <a class="portfolio-link-icon" href="http://www.elitesports.com"><
<img class="alignnone blackout size-full wp-image-2592" alt="Elite Sports" src="http://www.surgicalgeeks.com/wp-content/uploads/2013/04/es.jpg" width="300" height="300" />
<img class="zoom-link" src="http://www.surgicalgeeks.com/wp-content/uploads/2013/04/portfolio-link-icon.png" />
</a>
</div>
CSS
span4 {
background: #000;
margin: 35px 50px;
width: 300px !important;
height: 300px;
border: 5px solid black;
float: left;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
box-shadow: 1px 1px 5px #000;
}
.span4:hover {
overflow: hidden;
border: 5px solid #8b8c8d;
border-radius: 25%;
-webkit-transform: rotate(290deg);
-moz-transform: rotate(290deg);
-o-transform: rotate(290deg);
-ms-transform: rotate(290deg);
transform: rotate(290deg);
}
.blackout:hover {
opacity: .0;
}
.zoom-link {
top: 130px;
left: 130px;
position: absolute;
visibility: hidden;
}
.span4:hover .zoom-link {
position: absolute;
visibility: visible;
}
.span4:hover .blackout {
opacity: 0;
}
You can add the thumbnail when you hover over the link using the :after pseudo-element. I created a Pen that demonstrates this: http://codepen.io/Ghodmode/pen/xFmqf
This isn't an ideal solution, but it is entirely CSS. It would be better if I could get the value of the src attribute from the image and use that as the background url using the attr() (http://www.w3.org/TR/css3-values/#attr) CSS function, but I couldn't get that to work.
.span4 a.zoom-icon {
position: relative;
}
.span4 a.zoom-icon:hover:after {
content: "";
display: block;
position: absolute;
width: 50px;
height: 50px;
bottom: 10px;
right: 10px;
background-color: black;
background-image: url("http://bit.ly/XioiVs");
background-position: center;
background-repeat: no-repeat;
-webkit-background-size: contain;
-moz-background-size: contain;
-o-background-size: contain;
background-size: contain;
}
Related
I'm trying to get a transition hover effect on border that the border expands on hover.
h1 {
color: #666;
}
h1:after {
position: absolute;
left: 10px;
content: '';
height: 40px;
width: 275px;
border-bottom: solid 3px #019fb6;
transition: left 250ms ease-in-out, right 250ms ease-in-out;
opacity: 0;
}
h1:hover:after {
opacity: 1;
}
<h1>CSS IS AWESOME</h1>
I've tried this on Jsfiddle
To expand the bottom border on hover, you can use transform:scaleX'(); (mdn reference) and transition it from 0 to 1 on the hover state.
Here is an example of what the border hover effect can look like :
The border and transition are set on a pseudo element to prevent transitioning the text and avoid adding markup.
To expand the bottom border from left or right, you can change the transform-origin property to the left or right of the pseudo element:
h1 { color: #666;display:inline-block; margin:0;text-transform:uppercase; }
h1:after {
display:block;
content: '';
border-bottom: solid 3px #019fb6;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
}
h1:hover:after { transform: scaleX(1); }
h1.fromRight:after{ transform-origin:100% 50%; }
h1.fromLeft:after{ transform-origin: 0% 50%; }
<h1 class="fromCenter">Expand from center</h1><br/>
<h1 class="fromRight">Expand from right</h1><br/>
<h1 class="fromLeft">Expand from left</h1>
Note : You need to add vendor prefixes to maximize browser support (see canIuse).
Expand bottom border on hover with 2 lines
You can achieve this effect when the text spans on 2 lines. The before pseudo element is absolutely positioned to make underline of the first line with bottom:1.2em;:
h1 { position:relative;color: #666;display:inline-block; margin:0;text-transform:uppercase;text-align:center;line-height:1.2em; }
h1:after, h1:before {
display:block;
content: '';
border-bottom: solid 3px #019fb6;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
}
h1:before{
position:absolute;
bottom:1.2em; left:0;
width:100%;
}
.ef2:hover:after {
transition-delay:150ms;
}
h1:hover:after, h1:hover:before { transform: scaleX(1); }
<h1>Expand border<br/>on two lines</h1>
<br/>
<br/>
<h1 class="ef2">Expand border<br/>effect two</h1>
Different transition direction on hover in and out :
The point is to change the transform-origin position from one side to the other on the hover state. This way the bottom boder enters from one side on hover and exits on the other when the element isn't hovered anymore.
Here is a demo :
h1 { color: #666;display:inline-block; margin:0;text-transform:uppercase; }
h1:after {
display:block;
content: '';
border-bottom: solid 3px #019fb6;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
}
h1.fromLeft:after{ transform-origin: 100% 50%; }
h1.fromRight:after{ transform-origin: 0% 50%; }
h1.fromLeft:hover:after{ transform: scaleX(1); transform-origin: 0% 50%; }
h1.fromRight:hover:after{ transform: scaleX(1); transform-origin: 100% 50%; }
<h1 class="fromRight">Expand from right</h1><br/>
<h1 class="fromLeft">Expand from left</h1>
We can do this with only background. No pseudo-element needed. This is more flexible.
h1 {
/* you can change these variables to control the border */
--border-color: purple;
--border-width: 5px;
--bottom-distance: 0px; /* you can increase this */
color: #666;
display: inline-block;
background-image: linear-gradient(var(--border-color), var(--border-color));
background-size: 0% var(--border-width);
background-repeat: no-repeat;
transition: background-size 0.3s;
margin: 5px 0;
}
.fromCenter {
background-position: 50% calc(100% - var(--bottom-distance));
}
.fromRight {
background-position: 100% calc(100% - var(--bottom-distance));
}
.fromLeft {
background-position: 0 calc(100% - var(--bottom-distance))
}
h1:hover {
background-size: 100% var(--border-width);
}
<h1 class="fromCenter">Expand from center</h1><br/>
<h1 class="fromRight">Expand from right</h1><br/>
<h1 class="fromLeft">Expand from left</h1>
Multiple line animation:
h1 {
/* you can change these variables to control the border */
--border-color: purple;
--border-width: 5px;
--bottom-distance: 0px; /* you can increase this */
color: #666;
display: inline; /* should be 'inline' for multiple line animation */
background-image: linear-gradient(var(--border-color), var(--border-color));
background-size: 0% var(--border-width);
background-repeat: no-repeat;
transition: background-size 0.5s;
}
.fromCenter {
background-position: 50% calc(100% - var(--bottom-distance));
}
.fromRight {
background-position: 100% calc(100% - var(--bottom-distance));
}
.fromLeft {
background-position: 0 calc(100% - var(--bottom-distance))
}
h1:hover {
background-size: 100% var(--border-width);
}
<h1 class="fromLeft">Expand from <br>left with <br>multiple line</h1>
simple and lightweight version
li {
margin-bottom: 10px;
}
.cool-link {
display: inline-block;
color: #000;
text-decoration: none;
}
.cool-link::after {
content: '';
display: block;
width: 0;
height: 2px;
background: #000;
transition: width .3s;
}
.cool-link:hover::after {
width: 100%;
//transition: width .3s;
}
<ul>
<li><a class="cool-link" href="#">A cool link</a></li>
<li><a class="cool-link" href="#">A cool link</a></li>
<li><a class="cool-link" href="#">A cool link</a></li>
</ul>
I know this is an old post and it is already answered but you might like the following effect too.
<div class="cd-single-point">
<a class="cd-img-replace" href="#0"></a>
</div>
.cd-single-point {
position: absolute;
list-style-type: none;
left: 20px;
top: 20px;
}
.cd-single-point>a {
position: relative;
z-index: 2;
display: block;
width: 10px;
height: 10px;
border-radius: 50%;
background: #0079ff;
-webkit-transition: background-color 0.2s;
-moz-transition: background-color 0.2s;
-o-transition: background-color 0.2s;
transition: background-color 0.2s;
}
.cd-single-point::after {
content: '';
position: absolute;
border-radius: 50%;
width: 100%;
height: 100%;
top: 0;
left: 0;
animation: cd-pulse 2s infinite;
}
#keyframes cd-pulse
{
0% {box-shadow:0 0 0 0 #0079ff}
100%{box-shadow:0 0 0 20px rgba(255,150,44,0)}
}
DEMO
h1 {
color: #666;
display:inline-block;
margin:0;
text-transform:uppercase;
}
h1:after {
display:block;
content: '';
border-bottom: solid 3px #92a8d1;
transform: scaleX(0);
transition: transform 800ms ease-in-out;
}
h1:hover:after {
transform: scaleX(1);
}
<h1 class="fromCenter">Hover Over Me</h1><br/>
we can do using simple transition effect.
HTML
<h1>CSS IS AWESOME</h1>
CSS
h1 {
color: #666;
position: relative;
display: inline-block;
}
h1:after {
position: absolute;
left: 50%;
content: '';
height: 40px;
height: 5px;
background: #f00;
transition: all 0.5s linear;
width: 0;
bottom: 0;
}
h1:hover:after {
width: 270px;
margin-left: -135px;
}
Link to Fiddle
h1 {
/* you can change these variables to control the border */
--border-color: purple;
--border-width: 5px;
--bottom-distance: 0px; /* you can increase this */
color: #666;
display: inline-block;
background-image: linear-gradient(var(--border-color), var(--border-color));
background-size: 0% var(--border-width);
background-repeat: no-repeat;
transition: background-size 0.3s;
margin: 5px 0;
}
.fromCenter {
background-position: 50% calc(100% - var(--bottom-distance));
}
.fromRight {
background-position: 100% calc(100% - var(--bottom-distance));
}
.fromLeft {
background-position: 0 calc(100% - var(--bottom-distance))
}
h1:hover {
background-size: 100% var(--border-width);
}
<h1 class="fromCenter">Expand from center</h1><br/>
<h1 class="fromRight">Expand from right</h1><br/>
<h1 class="fromLeft">Expand from left</h1>
transition: all 1000ms ease-in-out;
Demo
or are you looking for this
Demo2
h1 {
color: #666;
}
h1:after {
position: absolute;
left: 10px;
content: '';
height: 40px;
width: 275px;
border-bottom: solid 3px #019fb6;
transition: all 550ms ease-in-out;
border-bottom-width: 0px;
}
h1:hover:after {
border-bottom-width: 5px;
}
<h1>CSS IS AWESOME</h1>
There is a problem on my website. I have a video
https://drive.google.com/file/d/1MWCynYB64jxXPYpYaa3LkplrwWGf1Xko/view
It only occurs on safari.
HTML
<div class="item">
<div class="img-wrapper">
<img class='img'>
</div>
</div>
CSS
.img-wrapper {
width: 220px;
height: 220px;
border: solid 8px #ffffff;
border-radius: 110px;
overflow: hidden;
}
.img {
width: 100%;
height: 100%;
-o-object-fit: cover;
object-fit: cover;
-webkit-transition: 0.2s;
transition: 0.2s;
border-radius: 110px;
}
.item:hover .img-wrapper img {
transform: scale(1.1);
}
It works properly (image zooms in while staying inside the border) on every other browser.
It seems a problem with transition.
.item:hover .img-wrapper img {
transform: scale(1.1);
transition: 0;
}
Help i work on hover link effect, the effect is opacity. The effect is working but it stop when i hover the caption inside it its stop the effect.
here the code of the css:
a .hover11 img {
opacity: 1;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
a .hover11 img:hover {
opacity: .5;
}
.imagebig {
position: relative;
width: 24%;
/* for IE 6 */
height: 60%;
background: #D9138E;
background: linear-gradient(#D9138E, rgba(0, 0, 0, 0));
border: solid 1px #FFFFFF;
display: inline-block;
}
h2 {
position: absolute;
bottom: -10px;
left: 0;
width: 100%;
display: block;
<a href="">
<div class="imagebig hover11" align="left">
<img style="width:100%; height:100%" src="//placehold.it/100" alt="" />
<h2>Kung Fu Panda</h2>
</div>
</a>
The last one is the html. Is there anyway to stop the h2 stopping the effect when hover ? I already try user-select its not work
try this
a .hover11:hover img {
opacity: .5;
}
instead of this :
a .hover11 img:hover{
opacity: .5;
}
You have given hover effect on image tag only that's the reason your hover effect don't work on text.
So instead of giving hover effect on image tag give hover effect on outer div and it will work for both image as well as text.
Use this:
a .hover11:hover img {
opacity: .5;
}
Just add pointer-events: none; this will prevent the hover effect on h2
a .hover11 img {
opacity: 1;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
a .hover11 img:hover {
opacity: .5;
}
.imagebig {
position: relative;
width: 24%;
/* for IE 6 */
height: 60%;
background: #D9138E;
background: linear-gradient(#D9138E, rgba(0, 0, 0, 0));
border: solid 1px #FFFFFF;
display: inline-block;
}
h2 {
position: absolute;
bottom: -10px;
left: 0;
width: 100%;
display: block;
pointer-events: none;
}
<a href="">
<div class="imagebig hover11" align="left">
<img style="width:100%; height:100%" src="//placehold.it/100" alt="" />
<h2>Kung Fu Panda</h2>
</div>
</a>
HTML:
<div class="mySlides">
<img src="1.jpg">
<img src="2.jpg"/>
<img src="3.jpg"/>
<img src="4.jpg"/>
<img src="5.jpg"/>
</div>
CSS:
.mySlides {
padding-top: 25%;
padding-left: 5%;
}
.mySlides img {
object-fit: cover;
position: absolute;
max-width: 35%;
}
.mySlides img:nth-of-type(1) {
left: 0%;
top: 0%;
-webkit-transform: rotate(5deg);
-moz-transform: rotate(5deg);
-o-transform: rotate(5deg);
transform: rotate(5deg);
}
This will be repeated for all images, i.e. nth-of-type(2,3,4,5)
.mySlides img {
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out;
-o-transition: all 0.25s ease-out;
transition: all 0.25s ease-out;
padding: 10px 10px 30px 10px;
background: linear-gradient(#ffffff, #eaeaea);
border: solid 1px black;
}
I wanted to stack the images on top of each other and have them all centered on the screen.
On hovering I wanted the images to separate horizontally while still maintaining the animation.
Check this out
Working fiddler https://jsfiddle.net/RaajNadar/L0ennqwp/
Html
<div class="mySlides">
<img src="http://lorempixel.com/400/200/">
<img src="http://lorempixel.com/400/200/sports"/>
</div>
css
.mySlides {
position: relative;
}
.mySlides img {
position: absolute;
top: 0;
left: 0;
max-width: 300px;
transition: left 1.2s ease-in-out;
}
.mySlides:hover img:last-child {
left: 300px;
}
Also got a nice animation.
Is this what you need?
.mySlides {
display: flex;
position: relative;
}
.mySlides img {
position: absolute;
top: 0;
left: 0;
}
.mySlides:hover img {
position: relative;
top: auto;
left: auto;
}
<div class="mySlides">
<img src="http://placehold.it/300x150/000000">
<img src="http://placehold.it/300x150/003300" />
<img src="http://placehold.it/300x150/00ff00" />
<img src="http://placehold.it/300x150/006600" />
<img src="http://placehold.it/300x150/ff0000" />
</div>
This is my structure:
<div class="parent">
<a href="#">
<p class="carousel_img">
<span class="img"></span>
Some text
</p>
</a>
and this is my style:
.parent{
height: 270px;
width: 270px;
}
.img {
background-image: url(http://frontendtest.ru/anit/img/ps_3.jpg);
background-size: cover;
display: block;
height: 250px;
overflow: hidden;
border-radius: 50%;
-webkit-transform: scale(1.3);
-ms-transform: scale(1.3);
transform: scale(1.3);
-webkit-transition: -webkit-transform 0.3s;
transition: -webkit-transform 0.3s;
transition: transform 0.3s;
transition: transform 0.3s, -webkit-transform 0.3s;
background-repeat: no-repeat;
}
.carousel_img {
border-radius: 50%;
border: 4px solid #f6e9d6;
height: 260px;
width: 260px;
overflow: hidden;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
position: relative;
margin: 0 auto;
}
a:hover .carousel_img {
border-color: #2e8ce4;
}
.carousel_img:before {
height: 15px;
width: 15px;
border-left: 2px solid #fff;
border-bottom: 2px solid #fff;
-webkit-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg);
margin: auto;
bottom: 20px;
z-index: 2;
}
.carousel_img:after {
content: '';
position: absolute;
left: 0;
right: 0;
display: none;
}
.carousel_img:after {
bottom: 0;
height: 56px;
background: #2e8ce4;
}
a:hover .carousel_img:before, a:hover .carousel_img:after {
display: block;
}
In Chrome, Firefox, Edge we can see a thin white line between blue :after element and blue border on bottom of picture when we :hover on image. This is a link on my pen http://codepen.io/DmitryShutov/pen/JKovYb.
How can I remove thin white line?