No, I have no code to demonstrate but I have been wondering: Is it possible to change a font-awesome logo with just transition? Such as: Change the class? I did a little bit of research on w3schools and How can create transition effect in font awesome icon found this link aswell, but they didn't really help and this question has been with me for a long time.
so, the question is: Is it possible to make a logo change (font awesome) with css transition or do I need javascript for it?
in case the question shouldn't be posted here. please tell me where it should so I can move it.
Cheers,
Here you go:
This has been done here: https://codepen.io/toaster99/pen/BpgzQR
HTML:
<div id="container">
<div class="button">
<div class="icons">
<i class="fa fa-apple icon-default"></i>
<i class="fa fa-arrow-circle-down icon-hover"></i>
</div>
Download
</div>
</div>
CSS:
#attribution {
position: fixed;
right: 10px;
bottom: 10px;
color: #FE8989;
z-index: 100;
font-weight: bold;
cursor: pointer;
a {
color: inherit;
text-decoration: inherit;
}
}
#container {
background: linear-gradient(#8affff,#80eded);
position: relative;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
}
.button {
position: relative;
margin-bottom: 40px;
display: inline-flex;
justify-content: center;
align-items: center;
background: #FE8989;
box-shadow: 0px 0px 0 0px rgba(0,0,0,0);
border-radius: 50px;
width: 25.25rem;
padding: 1rem 0;
font-family: 'Montserrat', sans-serif;
font-weight: 600;
font-size: 2.75rem;
color: white;
cursor: pointer;
-moz-transition: all 0.3s ease;
transition: all 0.3s ease;
.icons {
position: relative;
display: flex;
justify-content: center;
align-items: center;
margin: 0 2.3rem 0 0;
width: 1.25rem;
height: 2.6rem;
i {
position: absolute;
top: 0;
left: 0;
display: block;
}
.icon-default {
transition: opacity .3s, transform .3s;
}
.icon-hover {
transition: opacity .3s, transform .3s;
transform: rotate(-180deg) scale(.5);
opacity: 0;
}
}
&:hover {
transform: scale(1.2);
box-shadow: 20px 15px rgba(0,0,0,0.15);
.icon-hover {
transform: rotate(0deg) scale(1);
opacity: 1;
}
.icon-default {
transform: rotate(180deg) scale(.5);
opacity: 0;
}
}
}
yes, its pretty simple after you see the solution but I was confused too which led me to this post.
css
#keyframes pulse {
0% {
color:transparent;
}
50% {
color: #065803;
}
75% {
color:rgb(113, 139, 0);
}
100% {
color: #065803;
}
0% {
color:rgb(189, 176, 1);
}
}
#linked{
font-size: 16.5rem;
color: white;
display: flex;
justify-content: center;
}
i{
animation: pulse 8s infinite ease;
} ```
HTML
<i id="linked" class="fab fa-linkedin"></i>
</a>
</div>
<div class="col-2-of-2">
<a href="projects.html" target="_blank">
<i id="linked" class="fas fa-code"></i>
</a>
```
Related
I am creating a navigation bar for my project, but when I added a white background when pressing the buttons I noticed that they are not lining up correctly. I am trying to align them but have not succeeded. This is how they currently look:
This is my HTML:
<navbar>
<ul class="nav__list">
<li class="nav__item__logo" data-tooltip="NutritionistApp">
<a href="#">
<img src="../../imgs/navbar/NutritionistApp.svg" class="logo-item" alt="Icono NutritionistApp">
</a>
</li>
<li class="nav__item" data-tooltip="Inicio">
<a href="#">
<img src="../../imgs/navbar/Home.svg" class="filter-clr" alt="Icono Inicio">
<div class="btn-ellipse"></div>
</a>
</li>
<!-- Other <li> elements... -->
And all my CSS:
:root{
/* Colores */
--clr-primary: #452372;
--clr-btn-primary: #9D8FAD;
--clr-btn-primary-hover: #FFFFFF;
/* Border radius */
--radius: 0.2rem;
/* Font Size */
font-size: 16px;
}
*,
*::before,
*::after{
box-sizing: border-box;
margin: 0;
padding: 0;
}
body{
/* Font family */
font-family: "Metropolis", sans-serif;
}
.nav__list{
background: var(--clr-primary);
box-shadow: 0px 0px 10px #7b7b7b;
padding: 1rem 0;
width: 6rem;
height: 100vh;
position: fixed;
display: flex;
flex-direction: column;
align-items: center;
gap: 2rem;
z-index: 99;
}
.nav__item__logo{
list-style: none;
position: relative;
margin-bottom: 1.5rem;
transition: all 150ms ease;
}
.logo-item:hover{
transition: all 150ms ease;
transform: scale(1.05);
}
.nav__item{
list-style: none;
position: relative;
z-index: 99;
}
.nav__item::before{
content: attr(data-tooltip);
position: absolute;
left: 1rem;
top: -0.25rem;
background: var(--clr-primary);
color: white;
padding: 0.8rem;
border-radius: var(--radius);
transition: all 150ms ease;
opacity: 0;
scale: 0;
}
.nav__item::after{
content: "";
position: absolute;
width: 14px;
height: 14px;
border-radius: 2px;
background-color: transparent;
left: 5rem;
top: 0.6rem;
transition: all 150ms ease;
transform: rotate(45deg);
opacity: 0;
scale: 0;
}
.nav__item:hover::after{
opacity: 1;
scale: 1;
left: 5.1rem;
background-color: var(--clr-primary);
}
.nav__item:hover::before{
opacity: 1;
scale: 1;
left: 5.5rem;
}
.nav__item img{
transition: all 200ms ease-in;
}
.filter-clr:hover{
filter: brightness(0) saturate(100%) invert(99%) sepia(0%) saturate(2%) hue-rotate(359deg) brightness(111%) contrast(101%);
}
.btn-ellipse{
position: relative;
}
.btn-ellipse::before{
content: "";
width: 3rem;
height: 3rem;
background: white;
position: absolute;
border-radius: 50%;
left: -0.5rem;
top: -2.5rem;
z-index: -1;
opacity: 0;
transition: all 200ms ease-in;
}
.nav__item a:focus > .btn-ellipse::before{
opacity: 1;
}
.nav__item a:focus > img{
filter: brightness(0) saturate(100%) invert(16%) sepia(73%) saturate(1372%) hue-rotate(242deg) brightness(93%) contrast(101%);
}
I have a strong suspicion that if I change my current SVGs to others all the same size, it will center everything correctly, but I don't like that solution because I have icons with quite a lot of detail and I need each one to look big and clear.
I hope you can help me!
Hello so i made a gallery with images , and i added hover overlay to it, but also added lightbox, so now when i try to click on image i am clicking on overlay. how do i make it clickable trough hover layer that i made ?
.gallery-image{
position: relative;
width: 300px;
box-shadow: rgb(139, 9, 9) 0px 5px 10px;
}
.image-img{
width: 100%;
display: block;
}
.overlay{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
color: var(--tect-onblack);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
opacity: 0;
transition: all .4s ease;
}
.image-title i{
font-size: 70px;
}
.overlay:hover{
opacity: 1;
transition: all .4s ease;
cursor: pointer;
}
.overlay >*{
transform: translateY(30px);
transition: all .4s ease;
}
.overlay:hover >*{
transform: translateY(0);
}
<div class="gallery">
<div class="gallery-image">
<a href="./images/111.jpg" data-lightbox="shkaf" data-title="gal1">
<img class="image-img" src="./images/111.jpg"></a>
<div class="overlay">
<div class="image-title">
<i class='bx bx-zoom-in'></i>
</div>
</div>
<div class="price">
<p>120 000р</p>
</div>
</div>
Here's what I added/changed to achieve the desired effect (pure CSS alterations):
Moved the hover to .gallery .gallery-image and made it display: inline-block. This is so that overlay can still change, but its visual state is not tied to an event. Making it inline-block limits the hover area to the width of the content.
Added pointer-events: none to .overlay, so that mouse clicks will pass through it.
.gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, auto));
gap: 2rem;
align-items: center;
justify-content: space-evenly;
max-width: 1920px;
margin: 4rem auto 0 auto;
}
.gallery-image {
position: relative;
width: 300px;
box-shadow: rgb(139, 9, 9) 0px 5px 10px;
}
.image-img {
width: 100%;
display: block;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
color: var(--tect-onblack);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
opacity: 0;
transition: all .4s ease;
pointer-events: none;
}
.image-title i {
font-size: 70px;
}
.gallery-image:hover .overlay {
opacity: 1;
transition: all .4s ease;
cursor: pointer;
}
.overlay>* {
transform: translateY(30px);
transition: all .4s ease;
}
.overlay:hover>* {
transform: translateY(0);
}
<div class="gallery">
<div class="gallery-image">
<a href="./images/111.jpg" data-lightbox="shkaf" data-title="gal1">
<img class="image-img" src="./images/111.jpg"></a>
<div class="overlay">
<div class="image-title">
<i class='bx bx-zoom-in'></i>
</div>
</div>
<div class="price">
<p>120 000р</p>
</div>
</div>
</div>
I used the current clicked class to create a click event.
let imgs = document.querySelectorAll('.overlay');
imgs.forEach((img) => {
img.addEventListener("click", () => {
console.log("Image was clicked");
});
});
.gallery-image {
position: relative;
width: 300px;
box-shadow: rgb(139, 9, 9) 0px 5px 10px;
}
.image-img {
width: 100%;
display: block;
}
.overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
color: var(--tect-onblack);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
opacity: 0;
transition: all .4s ease;
}
.image-title i {
font-size: 70px;
}
.overlay:hover {
opacity: 1;
transition: all .4s ease;
cursor: pointer;
}
.overlay>* {
transform: translateY(30px);
transition: all .4s ease;
}
.overlay:hover>* {
transform: translateY(0);
}
<div class="gallery">
<div class="gallery-image">
<a href="./images/111.jpg" data-lightbox="shkaf" data-title="gal1">
<img class="image-img" src="./images/111.jpg"></a>
<div class="overlay">
<div class="image-title">
<i class='bx bx-zoom-in'></i>
</div>
</div>
<div class="price">
<p>120 000р</p>
</div>
</div>
Im making an online game and was making the play button, but had the following issue:
What i want to achieve:
What is happening:
For some reason the background of the text is getting transparent...
HTML:
.wrapper {
display: flex;
justify-content: center;
}
.cta {
display: flex;
padding: 10px 45px;
text-decoration: none;
font-family: "Ceviche One", sans-serif;
font-size: 55px;
color: white;
background: #6225e6;
transition: 1s;
box-shadow: 6px 6px 0 black;
transform: skewX(-15deg);
}
.cta:focus {
outline: none;
}
.cta:hover {
transition: 0.5s;
box-shadow: 10px 10px 0 #fbc638;
}
.cta span:nth-child(2) {
transition: 0.5s;
margin-right: 0px;
}
.cta:hover span:nth-child(2) {
transition: 0.5s;
margin-right: 45px;
}
span {
transform: skewX(15deg);
}
span:nth-child(2) {
width: 20px;
margin-left: 30px;
position: relative;
top: 12%;
}
<div class="wrapper">
<a class="cta" href="#">
<span>JUGAR</span>
</a>
</div>
Any idea how to fix this? It works fine in codepen but not in my project.
Because you are applying the color on class cta which is parent for the text JUGAR. You need to set the color to the span not a tag
I was accidentaly applying a background-color to everything with *{}
I'm dipping my toes into web design for now and I'm trying to replicate the "buy more" button animation from here( https://themes.getbootstrap.com/preview/?theme_id=67539 ). While I did find a solution for the border, I can't make a smooth animation for the icon(I am using font awesome), instead it just jumps directly.
Thanks in advance for the help
My CSS is this for the button is:
and the html for it is `Buy now <i class="fas fa-level-down-alt navbar__btn--i"></i>`
.navbar__btn {
position: relative;
font-size: 1.2rem;
color: #fff;
display: inline-block;
margin-right: 7rem;
padding-top: .5rem;
}
.navbar__btn:after {
margin-top: .3rem;
display: block;
content: " ";
border-bottom: solid 2px #fff;
transform: scaleX(0);
transform-origin: 0% 100%;
transition: all 1s ease-in-out;
}
.navbar__btn:hover:after {
transform:scaleX(1.2);
}
.navbar__btn:hover .navbar__btn--i {
left: 7rem;
}
.navbar__btn--i {
position: absolute;
top: 5px;
transition: all 1s linear 1s;
}
And the html is
Buy now <i class="fas fa-level-down-alt navbar__btn--i"></i>
Replace the appropriate icon. I designed it according to the link. You can adjust the delays to your liking
.navbar__btn {
position: relative;
font-size: 1.2rem;
color: #fff;
display: inline-block;
margin-right: 7rem;
padding-top: .5rem;
color:black;
text-decoration:none;
color:white;
}
.navbar__btn:after {
margin-top: .3rem;
display: block;
content: " ";
border-bottom: solid 2px #fff;
transform: scaleX(0);
transform-origin: 0% 100%;
transition: all .5s ease-in-out;
}
.navbar__btn:hover:after {
transform:scaleX(1.3);
}
.navbar__btn:hover .navbar__btn--i {
right: -20px;
}
.navbar__btn--i {
position: absolute;
top: 5px;
right:-10px;
line-height:0px;
transition: all .3s linear 0s;
vertical-align:middle;
margin-top:15px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div style="heigth:100px;width:500px;background:red;padding:5px;">
Buy now <i class="fas fa-arrow-right navbar__btn--i"></i>
</div>
I'm designing the front end of an e-commerce website and while looking through some inspiration I found a really nice effect involving a button and a after on that button, that when hovering over it, the text of the button would go up and at the same time an icon would replace it. You can see what I mean here. I probably won't use this on the project but I got really confused trying to mimic this effect while using Dev Tools, and just ending up with a cart icon on the bottom of the page and would love to know how to create something similar to this.
This is the final result
I almost got to something but I can't seem to make the text and the icon move at the same time, sometimes the icon wouldn't move at all and just the whole button would do, and not the text.
Any ideas on how this could be achieved with CSS? I already went through CodePen to find something similar and I'm not really sure how this effect is called to google it
EDIT: Already tried this code on an with a button class.
.button {
background: none;
font-weight: 600;
line-height: inherit;
margin: 0;
padding: 0 15px;
margin-top: 0;
position: relative;
text-align: center;
vertical-align: top;
-webkit-transition: color 0.15s linear 0s,-webkit-transform 0.3s linear 0s;
text-transform: uppercase;
transition: color 0.15s linear 0s,transform 0.3s linear 0s;
}
.button:hover {
-webkit-transform: translateY(-100%);
-moz-transform: translateY(-100%);
-ms-transform: translateY(-100%);
-o-transform: translateY(-100%);
transform: translateY(-100%);
}
.button:after {
background-color: inherit;
border-color: inherit;
border-style: inherit;
border-width: inherit;
font-size: 18px;
font-weight: 400;
height: auto;
margin: 0;
position: absolute;
left: 0;
top: 100%;
text-align: center;
width: 100%;
-webkit-transform: translateY(0);
transform: translateY(0);
-webkit-animation: none;
animation: none;
}
.button:hover:after {
top: 150%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
Here is a simple example using a psuedo element and font-awesome icon
.btn {
background-color: turquoise;
border-radius: 10px;
color: white;
padding: 5px 10px;
position: relative;
overflow: hidden;
height: 20px;
display: inline-block;
transition: all .3s;
}
.btn span {
position: relative;
top: 0;
transition: all .3s;
}
.btn::after {
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f217";
position: absolute;
left: 50%;
transform: translatex(-50%);
top: 40px;
transition: all .3s;
font-size: 20px;
}
.btn:hover {
background-color: blue;
}
.btn:hover span {
top: -30px;
}
.btn:hover::after {
top: 5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css" rel="stylesheet"/>
<a href="#" class="btn">
<span>Add to cart</span>
</a>
Here is a slightly simpler example using two different p tags instead of text/svg. It shouldn't be too much trouble to convert:
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
button {
width: 100px;
height: 40px;
overflow: hidden;
border: unset;
border-radius: 10px;
background-color: turquoise;
transition: all 200ms;
}
button:hover {
background-color: blue;
}
div {
height: 80px;
transform: translateY(0%);
transition: inherit;
}
div:hover {
transform: translateY(-50%)
}
p {
display: flex;
align-items: center;
justify-content: center;
color: white;
height: 50%;
font-size: 18px;
font-weight: 600;
}
<button>
<div>
<p class="one">text one</p>
<p class="two">text two</p>
</div>
</button>