Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move HTML element upwards on hover

People also ask

How do you change hover text in HTML?

Yes, you can use CSS content . To switch between the normal text and "Reply!", put the normal text in a span and hide that when hovering. button { width: 6em } button:hover span { display: none } button:hover:before { content: "Reply!" }

Does Z index affect hover?

If an element is transparent and the element with z-index:-1; is 'under' it. This stops the hover effects. Z-index can you see as elevations in a building, and you watching it from birdseye. You can't reach the basement if there is a floor above it, even if its build from glass.

Can you use hover in HTML?

A hover text (also known as a tooltip text) is used to display additional descriptions over an HTML element. The text only appears when the mouse cursor hovers over an object. There are two ways you can create a hover text for your HTML elements: Adding the global title attribute for your HTML tags.


You need not use keyframes for this simple animation. Just CSS transition is enough.

Set the transition property in the initial state style rules with the duration.

#arrow {
  position: relative;
  top: 0;
  transition: top ease 0.5s;
}
#arrow:hover {
  top: -10px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<div id="arrow">
  <a href="#"><i class="fa fa-arrow-down fa-2x"></i></a>
</div>

You could also try applying a negative margin-top on hover if your element is absolutely positioned:

div {
  padding: 1em;
  border: 1px solid #b5b5b5;
  border-radius: 10px;
  width: fit-content;
  transition: 0.5s;
}

div:hover {
  box-shadow: 0 0 3px black;
  margin-top: -10px;
}
<br/>
<div>
  <img src="https://www.gravatar.com/avatar/0fdacb141bca7fa57c392b5f03872176?s=48&d=identicon&r=PG&f=1">
</div>