How to achieve multiple icon hover transitions over one image - html

I am trying to achieve two hover effects on an image.
First, when the user hovers over an image a plus icon on the top right corner of the image appears.
Second, when the user hovers over the plus the icon changes to: “Add to collection”.
All these events need to be smooth transitions.
My first problem is I can't get any smooth transitions going for the first hover.
My second problem is I have no idea how to achieve the second hover - I've done a lot of Google searches but this doesn't seem to be a common effect.
Here is the code I have tried so far (with fill murray placeholder image):
HTML:
<div class="item">
<a href="#" class="item-link">
<img src="https://www.fillmurray.com/g/582/580" alt="dimsum">
</a>
</div>
CSS:
.item-link:hover:before {
content: '';
display: block;
position: absolute;
width: 58px;
height: 58px;
background-image: url('http://i.imgur.com/bWcylV3.png');
border-radius: 50%;
top: 10px;
right: 10px;
}
And here is the js fiddle
Here is the screenshots for what I want to achieve with the second hover:

Just did a little bit changes in your mark up and and find a solution for your issue. Yes, It's not possible to :hover a pseudo-element. Added a new div btn-plus and a span text for convenience. This is done using pure css. Hope this helps :)
.btn-plus:before {
content: '';
display: block;
position: absolute;
width: 58px;
height: 58px;
background-image: url('http://i.imgur.com/bWcylV3.png');
border-radius: 50%;
top: 0px;
right: 30px;
z-index: 1;
}
.btn-plus{
position: absolute;
display: block;
width: 200px;
height: 58px;
top: 30px;
right: 0;
opacity : 0;
transition: all ease .5s;
}
.item-link{
width: 100%;
height: 100%;
display: block;
}
.item-link img{
width: 100%;
}
span.text{
position : absolute;
top: 0px;
right: 0px;
color: #fff;
padding: 15px;
width: 150px;
height: 30px;
border-radius: 30px;
background: rgba(0, 0, 0, 0.5);
z-index: 0;
transition: all ease .5s;
opacity : 0;
}
.item-link:hover .btn-plus{
opacity : 1;
}
.btn-plus:hover span{
opacity : 1;
right: 30px
}
<div class="item">
<a href="#" class="item-link">
<img src="https://www.fillmurray.com/g/582/580" alt="dimsum">
<div class="btn-plus">
<span class="text">Add to list</span>
</div>
</a>
</div>

Related

Change image icon appears on hover but disappears with every mouse move

.profile__change-image-button should appear on hover (while the image changes opacity to 0.8) and clicking on it is supposed to open a form. With my current code, opacity is applied on hover and the icon does appear, but it disappears with every move of the mouse, which it makes it difficult to open the popup form. The end result should be- opacity changed to 0.8 on hover + icon appear and disappear only when the mouse moves outside the borders of the image. Thank you very much in advance!
.profile__user {
max-width: 583px;
display: flex;
position: relative;
}
.profile__image {
background-size: cover;
background-position: center;
width: 120px;
height: 120px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
}
.profile__change-image-button {
width: 26px;
height: 26px;
background: transparent;
border: none;
position: absolute;
left: 47px;
bottom: 56px;
}
.profile__change-image-button-hide {
display: none;
}
.profile__image:hover {
opacity: 0.8;
}
.profile__image:hover + .profile__change-image-button-hide {
display: block;
}
<div class="profile__user">
<div
class="profile__image"
title="An image of the French oceanographer- Jacques Cousteau"
></div>
<div class="profile__change-image-button-hide">
<button type="button" class="profile__change-image-button">
<img
src="<%=require('./images/edit-profile-icon.svg')%>"
alt="A vector image of a pen inside the profile image"
class="profile__change-image-icon"
/>
</button>
</div>
<div class="profile__info">
<h1 class="profile__title"></h1>
<button type="button" class="profile__edit-button">
<img
src="<%=require('./images/button-edit.svg')%>"
alt="A vector image of a pen inside the edit button"
class="profile__edit-icon"
/>
</button>
<p class="profile__subtitle"></p>
</div>
</div>
There is a lot of html and css rules going on so I simplified the code to give what I believe you are looking to do. Also I've imported an icon font to get the button image you described. It's not a vector graphic but it can be with a simple change.
#import url("https://cdn.jsdelivr.net/npm/bootstrap-icons#1.9.1/font/bootstrap-icons.css");
.profile__user {
position: relative;
display: inline-block;
}
.profile__image {
background-image: url("https://picsum.photos/id/1027/120");
height: 120px;
width: 120px;
border-radius: 50%;
border: none;
opacity: 1;
transition: opacity .5s;
}
.profile__change-image-button {
position: absolute;
height: 24px;
width: 24px;
bottom: 16px;
right: 16px;
padding: 4px;
border-radius: 5px;
border: none;
opacity: 0;
transition: opacity .5s;
}
.profile__image:hover {
opacity: .8;
}
.profile__image:hover .profile__change-image-button {
opacity: 1;
}
<div class="profile__user">
<div class="profile__image" title="An image of the French oceanographer- Jacques Cousteau">
<button type="button" class="profile__change-image-button">
<i class="bi bi-pencil-square"></i>
</button>
</div>
</div>

How do I use a ::after div within a ::before container?

Here is the situation:
I am using the following CSS to darken a cover-image, so I can write a headline on it. The button-style however doesn't apply when using it within the ::before container.
HTML
<main class="zimmer-cover-dark">
<div class="zimmer-cover-inside">
...
</div>
</main>
CSS
.zimmer-cover-dark {
position: relative;
height: 65em;
}
.zimmer-cover-dark::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url(resources/img/7.jpeg);
background-repeat: no-repeat;
background-size: cover;
-webkit-filter: brightness(35%);
}
.zimmer-cover-inside {
position: relative;
padding-top: 18em;
}
Now I want to add my button as follows:
HTML
<main class="zimmer-cover-dark">
<div class="zimmer-cover-inside">
<a href="">
<button type="button" class="custom-btn-open">
Book Now
</button>
</a>
</div>
</main>
CSS
button {
font-weight: 400;
border: solid 2px #585858;
outline: 0;
padding: 1rem 4rem;
font-size: 1.25rem;
letter-spacing: 0.00rem;
background-color: white;
border-radius: 0.35rem;
position: relative;
cursor: pointer;
}
button::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #a9c7b1;
z-index: -1;
border-radius: 0.35rem;
border: solid 2px #919191;
transition: all 0.3s ease-in-out;
}
button.custom-btn-open::after {
top: 0.5rem;
left: 0.5rem;
}
The button sadly doesn't appear in the right format. It just stays white and not the intended style. Whenever I insert the button outside a ::before div, it works. So I wonder, how to I approach this situation, and is there a way I can use both pseudo-elements together?
sorry i did not read your code, my eyes got catch by the z-index -1 of your ::after, may it be the problem?

how can I make my blurred image into a link (HTML)

I made my image blurred when you hover over it but every time I try to make the image clickable where it redirects to a new link, the image disappears on Chrome. How can I fix this?
This is the code I have right now for my blurred image:
<div class="textWithBlurredBg2">
<img src="https://taylorsdigigracelim.files.wordpress.com/2014/04/week-4-practical-ex-1.jpg"> </a>
<h2>travel</h2>
</div>
(that's my code in HTML)
.textWithBlurredBg2 {
width: 300px;
height: 200px;
display: inline-block;
margin: 4px;
position: relative;
transform: translate(370px, 200px);
}
.textWithBlurredBg2 img {
width: 100%;
height: 100%;
border-radius: 4px;
transition: .3s;
}
.textWithBlurredBg2:hover img{
filter: blur(2px) brightness(90%);
box-shadow: 0 0 9px #DA70D6;
}
.textWithBlurredBg2 :not(img) {
position: absolute;
top: 30%;
z-index: 1;
color: #fff;
text-align: center;
width: 100%;
}
(That's my code in CSS)

Exclude an div element from background overlay

Im trying to make a block with overlay hover effect (default: weak black background color - Hover: none black background) and an icon and text in the middle that stays in the same state all the way.
How do i get the icon and text to stay in the same state (no hover effect)?
Ive tried several rules to the overlay div and the icon div without any luck.
Is there any css rule that provide some kind of exclusion?
I managed to get it to work by adding them outside the divs that has overlay background, but it didnt work out well as the hover effect breaks when you hover over the icon and text.
Here is the code: https://www.w3schools.com/code/tryit.asp?filename=FEMUM4N9T30Q
<style>
.media-front-top-picture{
background-image: url("");
height:500px;
}
.media-front-top-icon{
content: url(");
width: 130px;
margin: auto;
padding-top: 200px;
opacity: 1;
}
.media-front-txt{
font-size: 22px;
letter-spacing: 8px;
color: white;
margin-top: 15px;
}
.media-front-bottom-picture{
background-image: url("h");
height:500px;
}
.media-front-bottom-icon{
content: url("");
width:130px;
margin: auto;
padding-top: 200px;
}
.media-picture-container {
position: relative;
}
.media-picture-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
transition: .5s ease;
background-color: rgba(0, 0, 0, 0.47);
}
.media-picture-overlay:hover {
opacity: 0;
cursor:pointer;
}
</style>
<div class="body-media">
<div class="media-picture-container">
<div class="media-front-top-picture" style="border-bottom:4px solid white;">
<div class="media-front-top-icon"></div>
<div class="media-front-txt">VIDEOS</div>
<div class="media-picture-overlay"></div>
</div>
</div>
<div class="media-picture-container">
<div class="media-front-bottom-picture" style="border-bottom:4px solid white;">
<div class="media-front-bottom-icon"></div>
<div class="media-front-txt">PICTURES</div>
<div class="media-picture-overlay"></div>
</div>
</div>
</div>
for the classes on your icons, add a z-index higher than a z-index you add to the overlay class. Also, make sure to make the icon classes have position:relative so the z-index is applied. Note, my example only applies this solution to one icon, its up to you to apply it elsewhere.
Example:
.media-front-top-icon{
content: url("example.com");
width: 130px;
margin: auto;
padding-top: 200px;
opacity: 1;
z-index:10;
position:relative;
}
.media-picture-overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
transition: .5s ease;
background-color: rgba(0, 0, 0, 0.47);
z-index:5;
}

How can I add a "plus sign/icon" to my portfolio shots???

I am trying to add a "plus sign" (its a .png file) to my portfolio section. My goal is to make this "plus sign" visible only when customers are hovering with mouse pointer over my projects but in the same time I want to keep the background-color property which I already set up.
However, my plus sign doesn't show up!? How can I do that???
On this website you can see the similar effect: http://bjorsberg.se/
Here is my JSFiddle: http://jsfiddle.net/L8HX7/
This is a part of my CSS (from JSFiddle) that needs to be fixed:
.plus{
width: 100px;
height: 100px;
position: absolute;
left: 50%;
top: 50%;
margin: -49px 0 0 -56px;
background: url(img/plus.png) center center no-repeat;
}
Here is example of a plus sign I want to add: http://icons.iconarchive.com/icons/visualpharm/icons8-metro-style/512/Very-Basic-Plus-icon.png
Here is a really broken down example.
http://jsfiddle.net/sheriffderek/UVvWm/
CSS
.block {
position: relative; /* so the .plus knows what to be relative to */
display: block;
width: 10em;
height: 10em;
background-color: red;
}
.overlay {
position: absolute;
width: 100%;
height: 100%;
top: 0; left: 0;
}
.block:hover .overlay {
background-color: rgba(0,0,0,.5);
}
.block .plus {
display: none;
}
.block:hover .plus {
display: block;
}
/* to position the .plus */
.plus {
position: absolute;
left: 50%;
top: 50%;
margin-left: -50px;
margin-top: -50px;
}
HTML
<a href="#"class="block">
<div class="overlay"></div>
<img class="plus" src="http://placehold.it/100x100" />
</a>
You could use an :after psuedo element for the overlay - but I wanted to keep it simple. Keep in mind that CSS declarations read from right to left .... "any .plus - do this, when .block:hover" etc ----
The style obviously has to be applied on hover.
Just replace the background-color in .projectshot a .over:hover{ by the appropriate background. You don’t need the div.plus at all, and neither do you need div.inner (you can remove those from the HTML!):
.projectshot a .over:hover{
position: absolute;
background: url(img/plus.png) center center no-repeat rgba(51, 51, 51, 0.6);
border-radius: 8px;
height: 150px;
width: 200px;
margin: 10px;
}
Here’s the updated Fiddle: http://jsfiddle.net/L8HX7/8/