This question already has answers here:
CSS transform doesn't work on inline elements
(2 answers)
Closed 14 days ago.
I am trying to do a css animation on different spans as i hover over them but they are not working and i cant figure out why.
This is my html:
<div className="content">
<h2>Hello, I´m <br/>
<span className='bounce'>M</span>
<span className='bounce'>a</span>
<span className='bounce'>t</span>
<span className='bounce'>e</span>
<span className='bounce'>o </span>
<span className='bounce'>G</span>
<span className='bounce'>h</span>
<span className='bounce'>i</span>
<span className='bounce'>d</span>
<span className='bounce'>i</span>
<span className='bounce'>n</span>
<span className='bounce'>i</span></h2>
<div className="animated-text">
<h3>Web Designer</h3>
<h3>Jr Full-stack Web Developer</h3>
</div>
<Button className="btn" content="See My Work"/>
<div className="media-icons">
<i className="fab fa-linkedin-in"></i>
<i className="fab fa-github"></i>
</div>
</div>
And this is my css:
.main .content h2{
color:#FFF;
font-size:2em;
font-weight:500;
}
.main .content h2 span{
font-size:2.8em;
font-weight:600;
}
.main .content h2 span:hover{
color: #08fdd8;
animation: animate 0.6s;
}
#keyframes animate {
25%{
transform: scale(0.8, 1.3);
}
50%{
transform: scale(1.1, 0.8);
}
75%{
transform: scale(0.7, 1.2);
}
}
So as i hover the property that changes the color works, but it seems that the animation isn´t being triggered or something because it doesn´t do anything
You should put display: inline-block on those spans for animation to work. You can't manipulate the size of them as they are inline elements by default:
.main .content h2 span{
font-size:2.8em;
font-weight:600;
display: inline-block;
}
Related
Please, could someone help me accomplish the letter spinning effect on hover on this site? I managed to spin letters individually, but I'd like the whole word to flip with some delay among letters.
I've mostly followed this video. My code looks like this:
{/* html */}
<h1 className={styles.title}>
<div className={styles.letter_container}>
<span className={styles.letter}>s</span>
<span className={styles.letter}>o</span>
<span className={styles.letter}>n</span>
<span className={styles.letter}>g</span>
</div>
<div className={styles.letter_container}>
<span className={styles.letter}>o</span>
<span className={styles.letter}>f</span>
</div>
<div className={styles.letter_container}>
<span className={styles.letter}>t</span>
<span className={styles.letter}>h</span>
<span className={styles.letter}>e</span>
</div>
<div className={styles.letter_container}>
<span className={styles.letter}>d</span>
<span className={styles.letter}>a</span>
<span className={styles.letter}>y</span>
</div>
</h1>
/* css */
.letter_container {
display: flex;
flex-direction: row;
}
.letter {
cursor: pointer;
font-size: 4rem;
}
.letter_container span:hover {
animation: spin 1s infinite;
}
#keyframes spin {
from {
transform: rotateY(0deg);
}
to {
transform: rotateX(360deg);
}
}
Thank you in advance.
I'm not too sure, but if you'd like to spin the letters individually with delays between them like in the site, you could just add classes to the letters and make the whole animation start if they hover over the word.
.letter-1 {
transition-delay: 0.1s;
}
.letter-2 {
transition-delay: 0.1s;
}
or just add delays in-line style="--delay: 0.1s;" which is what they used in the website. I haven't looked into it too much so try inspecting the website's elements.
Extra CSS animation libraries if you still need them: Animate.css, Animista
My current website is having "issues" (not really a issue just bothers me) with my buttons hiding when the resolution changes to something smaller. Here is a gif so you understand it better. https://i.imgur.com/nlkJs5G.gifv. How can I fix it so it shrinks with the page so people can still click it on different screen resolutions?
Underneath is the html for the buttons. The .css for fab or fa-steam-symbol or fa-discord etc. is from https://fontawesome.com/ (if anyone is not familiar with it)
.awrapper{
align-content:center;
background-size:cover;
display:flex;
display:-ms-flexbox;
display:-webkit-flex;
flex-direction:row;
flex-wrap:wrap;
justify-content:center;
min-height:100%;
ms-flex-direction:row;
ms-flex-line-pack:center;
ms-flex-pack:center;
ms-flex-wrap:wrap;
webkit-align-content:center;
webkit-flex-direction:row;
webkit-flex-wrap:wrap;
webkit-justify-content:center;
}
.media{
font-size:30px;
text-align:center;
padding-top:30px;
}
.media>a{
margin-right:80px;
text-decoration:none;
transition:color 0.5s ease;
}
.media>a#vk{
font-size:35px;
}
.media>a:last-child{
margin-right:0;
}
.animated{
-webkit-animation-duration:2s;
animation-duration:3s;
-webkit-animation-fill-mode:both;
animation-fill-mode:both
margin: 500px
}
#-webkit-keyframes fadeInUpBig{
from{
opacity:0;
-webkit-transform:translate3d(0,2000px,0);
transform:translate3d(0,2000px,0)
}
to{
opacity:1;
-webkit-transform:none;
transform:none
}
}
#keyframes fadeInUpBig{
from{
opacity:0;
-webkit-transform:translate3d(0,2000px,0);
transform:translate3d(0,2000px,0)
}
to{
opacity:1;
-webkit-transform:none;
transform:none
}
}
.fadeInUpBig{
-webkit-animation-name:fadeInUpBig;
animation-name:fadeInUpBig
}
.hvr-grow {
display: inline-block;
vertical-align: middle;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px transparent;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-property: transform;
transition-property: transform;
}
.hvr-grow:hover, .hvr-grow:focus, .hvr-grow:active {
-webkit-transform: scale(2);
transform: scale(2);
}
<div class="awrapper">
<div class="media animated fadeInUpBig" style="animation-delay: 5s;">
<a href="BLNAK_LINK/Steam" target="_blank">
<i class="fab fa-steam-symbol hvr-grow" title="Steam"></i>
<a href="BLNAK_LINK/discord" target="_blank">
<i class="fab fa-discord hvr-grow" title="Discord"></i>
</a>
<a href="BLNAK_LINK/hosting" target="_blank">
<i class="fab fa-ioxhost hvr-grow" title="Hosting"></i>
</a>
<a href="BLNAK_LINK/TRADEOFFER" target="_blank">
<i class="far fa-handshake hvr-grow" title="Tradelink"></i>
</a>
<a href="BLNAK_LINK/PLAYLIST" target="_blank">
<i class="fas fa-music hvr-grow" title="Playlist"></i>
</a>
</div>
</div>
If I am missing anything or if you have questions please let me know and I will try to answer them.
Thanks for your help guys. You can check out the site and how it looks.
I added a new class called unmoveable
From
<div class="media animated fadeInUpBig" style="animation-delay: 5s;">
To
<div class="media animated fadeInUpBig unmoveable">
The css
.unmoveable {
animation-delay: 5s;
position:fixed;
bottom: 100px;
}
I am currently trying to make a h1 link that transforms when hovering over it. This works perfectly, when placing the /a outside of h1 However, doing this resolves in making the whole element react and clickable when hovering over it - it just looks bad. Placing /a inside /h1 makes only the text clickable as desired - yet it doesn't react to hover, but to all other changes it does.
Please note that I am a beginner and I do not know what exact context is required for you to help me.
This lets hover work, but makes the whole element clickable.
#headlines a:hover {
transform: scale(1.5);
transition: 0.1s;
}
<div class="grid_6" style="color: black; text-align: center">
<a href="headlines.html"
id="headlines"
style="text-decoration: none; color: black">
<h1> Headlines
</h1></a>
<hr>
</div>
Apply transform to the h1 on hover...but make the h1 as display:inline-block so it's no bigger than it needs to be.
The link will always be clickable but it should solve the sizing issue.
a#headlines h1 {
display: inline-block;
}
a#headlines h1 {
transition: transform .5s ease;
}
a#headlines h1:hover {
transform: scale(1.5);
}
<div class="grid_6" style="color: black; text-align: center">
<a href="headlines.html" id="headlines" style="text-decoration: none; color: black">
<h1> Headlines
</h1>
</a>
<hr>
</div>
you can try it
a#headlines:hover {
transition: transform .5s ease;
transform: scale(1.5);
}
Just add this:
a {
font-weight: bold;
font-size: 45px;
transition: all 500ms;
}
a:hover {
font-size:60px;
font-size-adjust: 20px;
}
This is the Fiddle
I am trying to create a hamburger menu button on a navbar inside a mobile web. This is my first time to build mobile web. And this code only show a huge square kind button instead of a nice hamburger menu. Please help.
<nav class="navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand ui-link" onclick="window.location.href='/'"href</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#popup">
<span class="text">Menu</span>
<span class="icon-bars">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</span>
</button>
</div>
</div>
</nav>
I'm not quite sure what you're trying to accomplish, but one thing you are missing in your "hamburger menu" is a color for the "bars".
So if you just add for example a background-color to your icon-bar elements it will show the hamburger menu.
.icon-bar {
background-color: black;
}
JSFiddle
You can just embed this code where you want a hamburger menu and it will automatically display the menu:
<svg>
<path fill="black" d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path>
</svg>
div {
width: 35px;
height: 5px;
background-color: black;
margin: 6px 0;
}
<p>A humburger icon:</p>
<div></div>
<div></div>
<div></div>
The problem in your code is that you used a span instead of a div, which has made all the difference, because span is an inline element and div is a block level element.
Using divs with some CSS as mentioned in this answer can help, but there are many ways through it.
You can use SVG, if you want a simple icon. It has been mentioned in this answer, but I'll still quote it:
<svg>
<path fill="black" d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path>
</svg>
You can also create an animated icon, like this:
function myFunction(x) {
x.classList.toggle("change");
}
.container {
display: inline-block;
cursor: pointer;
}
.bar1, .bar2, .bar3 {
width: 35px;
height: 5px;
background-color: #333;
margin: 6px 0;
transition: 0.4s;
}
/* Rotate first bar */
.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-9px, 6px) ;
transform: rotate(-45deg) translate(-9px, 6px) ;
}
/* Fade out the second bar */
.change .bar2 {
opacity: 0;
}
/* Rotate last bar */
.change .bar3 {
-webkit-transform: rotate(45deg) translate(-8px, -8px) ;
transform: rotate(45deg) translate(-8px, -8px) ;
}
<div class="container" onclick="myFunction(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
Hope I could help
I'm searching a way to make an css effect but with exception of not applying the effect to the letters and the buttons (Only to the image), so I need create a rule in css. I can't change the order of the things.
With my code, I get something like this.
This is my code, like you can see I applied some effect in css and this is getting applied to all. I only need it for the image.
.myimage01 {
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.myimage01:hover {
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01" data-style="background-image: url(http:www.myurl.com/image.jpg);padding: 40px 30px ;color: #ffffff;text-align: center;">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
When I apply the effect apply the effect to the letters (h5, h3, p and the button with btn class)
I don't want the effect for them, only for the background-image.
How can I do?
for transition backgrounds use the property background-size, and use background-position to adjust as fits you better
body {
margin: 0
}
.myimage01 {
background-size: 100%;
background-position:center center;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
background-image: url(http://lorempixel.com/1600/900);
padding: 40px 30px;
color: #ffffff;
text-align: center;
}
.myimage01:hover {
background-size: 130%;
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>
Use background-size for transition:
div {
background-image: url(http://lorempixel.com/400/200/sports/1/);
background-size: 100%;
background-repeat:no-repeat;
background-position:50% 50%;
width:400px;
height:200px;
transition: background-size 200ms linear;
text-align:center;
line-height:200px;
}
div:hover {
background-size: 120%;
}
<div>
Some text
</div>
try to transform the background-size property instead of scaling the whole container.
You can apply transform on background-size, background-position to get the effect on the background image.
.myimage01 {
background-size:100%;
background-position:0px 0px;
-webkit-transform: all;
transform: all;
-webkit-transition: .3s ease-in-out;
transition: .3s ease-in-out;
}
.myimage01:hover {
background-size:140%;
background-position:-50px -50px;
-webkit-transform: all;
transform: all;
}
<li id="armonioso-text-2" class="widget widget_armonioso_text">
<div class="armonioso-textwidget-wrapper armonioso-textwidget-no-paddings">
<!-- Here I'm currently Applying the efect -->
<div class="armonioso-textwidget myimage01" style="background-image: url(http://dummyimage.com/600x200/000/fff);padding: 40px 30px ;color: #ffffff;text-align: center;">
<h5>hello world</h5>
<h3>Here how works</h3>
<p>Take a look of new things
<p><a class="btn alt" href="about/index.html" target="_self">About me</a>
</div>
</div>
<!-- Here I'm currently Applying the efect -->
</li>