I'm learning CSS3 Transform and Transition and I added translateY(-40px) on text of 'Velodyne vTrue Forged Aluminum Performance Studio Headphones w/ Leather (Refurb) $80 + Free Shipping' but this gonna move back to start point if I hover a mouse point on the box. This problem on Chrome and Firefox. (style name '.area:hover desc')
I uploaded sample code to http://jsfiddle.net/tza1515g
Please answer me what I wrong.
<style>
.area {
width: 200px;
float: left;
border: 1px solid #ddd;
margin: 5px;
padding: 20px;
text-align: center;
height: 230px;
transition: background 0.3s;
background: #333;
color: #fff;
}
.area:hover {
background: #0CF;
}
.icon {
width: 50px;
transition: transform 0.3s cubic-bezier(0, 0, 0, 2);
transform: scale(1.5);
-webkit-transition: transform 0.3s cubic-bezier(0, 0, 0, 2);
-webkit-transform: scale(1.5);
color: #fff;
}
.area:hover .icon {
transform: scale(1);
}
.area h2 {
font-weight: 700;
text-transform: uppercase;
transition: transform 0.3s cubic-bezier(0, 0, 0, 2);
-webkit-transition: transform 0.3s cubic-bezier(0, 0, 0, 2);
}
.area:hover h2 {
transform: scale(0.8) translateY(-25px);
-webkit-transform: scale(0.8) translateY(-25px);
}
.desc {
opacity: 0;
color: #fff;
transition: all 0.2s;
-webkit-transition: all 0.2s;
}
.area:hover .desc {
opacity: 1;
transform: translateY(-40px);
-webkit-transform: translateY(-40px);
}
</style>
<figure class="area">
<img class="icon" src="data:image/png;base64,"/>
<figcaption>
<h2>Standard Management</h2>
<span class="desc">
Velodyne vTrue Forged Aluminum Performance Studio Headphones w/ Leather (Refurb) $80 + Free Shipping
</span>
</figcaption>
</figure>
When you are using the webkit version of the CSS rule, for example in line 26, use -webkit-transition in the property to undergo transition instead of simply transform.
Also, you forgot the webkit version in line 31(not an error just pointing it out).
Also, it is working here, but the transition is not very smooth, so is that what you are asking us to help you with?
Related
I want a picture to slide (with keyframes), and wen :hover that its scale grows, and when :active, decrease its scale. When i do so, it only slides, :hover and :active don´t work... Please help
#slide-right {
margin-left: 25px;
margin-right: 25px;
margin-bottom: 25px;
height: 250px;
box-shadow: 0px 1px 5px grey;
border-radius: 10px;
transition: .5s;
animation: slide-right 1s ease-out both;
}
#slide-right:hover {
transition: .5s;
transform: scale(1.04);
}
#slide-right:active {
transition: .2s;
transform: scale(0.95);
}
#keyframes slide-right {
0% {
transform: translateX(0);
}
100% {
transform: translateX(+200px);
}
}
<img src="https://www.w3schools.com/w3css/img_lights.jpg" id="slide-right">
#slide-right {
position: relative;
margin-left: 25px;
margin-right: 25px;
margin-bottom: 25px;
height: 250px;
box-shadow: 0px 1px 5px grey;
border-radius: 10px;
transition: .5s;
animation: slide-right 1s ease-out forwards;
}
#keyframes slide-right{
0% {
left: 0px;
}
100% {
left: 200px;
}
}
#slide-right:hover {
transition: .5s;
transform: scale(1.04);
}
#slide-right:active {
transition: .2s;
transform: scale(0.95);
}
<img src="https://www.w3schools.com/w3css/img_lights.jpg" id="slide-right">
It is happening because your key-frames animation is using css transform property and css for hover also uses transform to scale the image. So, only one of it will work at a time.
As a workaround for this problem, you can animate the entry of image using position.
Add position:relative to #slide-right and update your key-frames to 0%{left:0} and 100%{left:200px}.
For working example, please refer : this
I need to display a text on the image using CSS. I'm doing that using H2 tag:
<h2 class="post-message">Test</h2>
Here is the code for CSS:
.post-message {
position: absolute;
bottom: 10px;
left: 10px;
background: rgba(0, 0, 0, 0.75);
padding: 4px 8px;
color: white;
margin: 0;
font: 14px Sans-Serif;
}
But the overlay effect is messing things up and here is the code:
.overlay{
overflow: hidden;
background: #000;
}
.overlay img{
-webkit-transition: -webkit-transform .3s ease-out;
-moz-transition: -moz-transform .3s ease-out;
-o-transition: -o-transform .3s ease-out;
transition: transform .3s ease-out;
}
.overlay:hover img{
-webkit-transform: scale(1.2) rotate(-5deg);
-moz-transform: scale(1.2) rotate(-5deg);
-o-transform: scale(1.2) rotate(-5deg);
-ms-transform: scale(1.2) rotate(-5deg);
transform: scale(1.2) rotate(-5deg);
opacity: 0.7;
}
I don't know how to explain what happens and I uploaded 2 screens:
This screen shows the original image without Mouse hover: https://s22.postimg.org/xrsohlcw1/without_mouse_over.jpg
On the first image you see a gray background that I don't know from where comes
The second image is the mouse over effect: that gray image is rotating according to overlay effect and is displayed at the right corner only :/
https://s22.postimg.org/a13x0ndmp/gra_color_disappears.jpg
A little red arrow will show you what happens on the second image. A help would be great! I tried all possible things that I knew, expert opinion always is the best solution. Thanks in advance!
<div class="post-thumbnail overlay">
<a href="http://example.com/comey-wikileaks/">
<img src="http://example.com/wp-content/uploads/2017/04/comey-825x510.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" width="825" height="510">
</a>
<h2 class="post-message">Test</h2>
</div>
An img has a "replaced content" layout model and basically treated as an inline element, and that includes space at the bottom by default for the bottom part of characters, so there will be a small space between the bottom of an img and the bottom of the img's container. To remove that gap at the bottom, either make the img display: block or use vertical-align: top.
If the image is rotating so far that you see the corner of it in the bottom/right corner, either increase your scale() or don't rotate as much until you can't see that anymore. I don't see it with the code you provided.
.post-message {
position: absolute;
bottom: 10px;
left: 10px;
background: rgba(0, 0, 0, 0.75);
padding: 4px 8px;
color: white;
margin: 0;
font: 14px Sans-Serif;
}
.overlay {
overflow: hidden;
background: #000;
}
.overlay img {
-webkit-transition: -webkit-transform .3s ease-out;
-moz-transition: -moz-transform .3s ease-out;
-o-transition: -o-transform .3s ease-out;
transition: transform .3s ease-out;
}
.overlay:hover img {
-webkit-transform: scale(1.2) rotate(-5deg);
-moz-transform: scale(1.2) rotate(-5deg);
-o-transform: scale(1.2) rotate(-5deg);
-ms-transform: scale(1.2) rotate(-5deg);
transform: scale(1.2) rotate(-5deg);
opacity: 0.7;
}
img {
vertical-align: top;
}
<div class="post-thumbnail overlay">
<a href="http://example.com/comey-wikileaks/">
<img src="http://kenwheeler.github.io/slick/img/fonz1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" width="825" height="510">
</a>
<h2 class="post-message">Test</h2>
</div>
You could actually put your img together with your <h2> inside a <div> and let the whole <div> rotate....
Here is an example base on what you wrote:
(obvously, there's a few things to readjust, but it's more or less what you want, I guess ^^)
.post-message {
position: absolute;
bottom: 10px;
left: 10px;
background: rgba(0, 0, 0, 0.75);
padding: 4px 8px;
color: white;
margin: 0;
font: 14px Sans-Serif;
}
.overlay{
overflow: hidden;
background: #000;
/*these two lines are new*/
display:inline-block;
position:relative;
}
/*I apply style directly on the "overlay"*/
.overlay /*img*/{
-webkit-transition: -webkit-transform .3s ease-out;
-moz-transition: -moz-transform .3s ease-out;
-o-transition: -o-transform .3s ease-out;
transition: transform .3s ease-out;
}
.overlay:hover /*img*/{
-webkit-transform: scale(1.2) rotate(-5deg);
-moz-transform: scale(1.2) rotate(-5deg);
-o-transform: scale(1.2) rotate(-5deg);
-ms-transform: scale(1.2) rotate(-5deg);
transform: scale(1.2) rotate(-5deg);
opacity: 0.7;
}
<span class="overlay">
<img src="https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg" />
<h2 class="post-message">Test</h2>
</span>
I have a menu, and on each <li> there's a class making it overflow: hidden; so I can achieve an animation on it. The thing is on one of these list-item's there's a sub-menu. This sub-menu is position: absolute;. The overflow is making it so you can't see it when it's being clicked on. If I remove overflow: hidden; the animation breaks. I'm not sure what to do. Unless there's a way to bypass, I'm thinking for my sub-menu to appear I'd have to scrap the animation entirely.
Animation
/* Wayra */
.wayra {
overflow: hidden;
-webkit-transition: border-color 0.3s, color 0.3s;
transition: border-color 0.3s, color 0.3s;
-webkit-transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
}
/*.wayra.contact-item {
overflow: visible;
}*/
.wayra::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 150%;
height: 100%;
background: #281879;
/*z-index: -1;*/
-webkit-transform: rotate3d(0, 0, 1, -45deg) translate3d(0, -3em, 0);
transform: rotate3d(0, 0, 1, -45deg) translate3d(0, -3em, 0);
-webkit-transform-origin: 0% 100%;
transform-origin: 0% 100%;
-webkit-transition: -webkit-transform 0.3s, opacity 0.3s, background-color 0.3s;
transition: transform 0.3s, opacity 0.3s, background-color 0.3s;
}
.wayra a {
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
}
.wayra a:hover {
color: #fff;
}
.wayra:hover::before {
opacity: 1;
background-color: #281879;
-webkit-transform: rotate3d(0, 0, 1, 0deg);
transform: rotate3d(0, 0, 1, 0deg);
-webkit-transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
transition-timing-function: cubic-bezier(0.2, 1, 0.3, 1);
}
Dropdown
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
display: none;
float: left;
min-width: 160px;
padding: 5px 0;
margin: 2px 0 0;
font-size: 14px;
text-align: left;
list-style: none;
background-color: #fff;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
box-shadow: 0 6px 12px rgba(0,0,0,.175);
}
Here's a link to a demo.
How about adding that effect to a instead of li? Let's translate:
.wyara should get overflow:visible,
.wyara > a should get overflow:hidden,
.wayra::before becomes .wayra > a::before,
.wayra:hover::before becomes .wyara:hover > a::before, .wayra.open > a::before
Just tried it with Stylish, looks good.
Yes, you can override it when hovering over the element:
.wayra:hover {
overflow: visible;
}
I strongly believe that is not possible. But there have to be other methods to do something like this. If you want to have an animation, you will have to rewrite your menu from scratch.
So here's my fiddle
HTML
<div class="container">
<div class="cardItem">
<h1>Mouse over me</h1>
<p>Keep moving the mouse during transition</p>
<p>Also have the mouse still over where the new
paragraph will come before the transition finishes</p>
<div class="cardHoverSide">
<p>See if my hover state still
fires despite your <span>crazy</span> mouse movements</p>
<div class="cardItem">NestedCard With Hover!</div>
</div>
</div>
</div>
CSS
.container {
overflow: hidden;
height: 17em;
width: auto;
}
.cardItem {
position: relative;
float: left;
margin: 0 .35em;
border: none;
background: #444;
color: #eee;
width: 10em;
height: 17em;
-moz-transition: transform .3s cubic-bezier(0, 0.59, 0, 0.99);
-o-transition: transform .3s cubic-bezier(0, 0.59, 0, 0.99);
-webkit-transition: transform .3s cubic-bezier(0, 0.59, 0, 0.99);
transition: transform .3s cubic-bezier(0, 0.59, 0, 0.99);
}
.cardHoverSide .cardItem {
width: 60%;
height: 50%;
}
.cardHoverSide .cardItem:hover {
background: #eee;
color: #222;
transform: initial;
}
.cardItem:hover {
-moz-transform: translate(0, -17em);
-ms-transform: translate(0, -17em);
-o-transform: translate(0, -17em);
-webkit-transform: translate(0, -17em);
transform: translate(0, -17em);
-moz-transition: transform .3s cubic-bezier(1, .01, 1, .41);
-o-transition: transform .3s cubic-bezier(1, .01, 1, .41);
-webkit-transition: transform .3s cubic-bezier(1, .01, 1, .41);
transition: transform .3s cubic-bezier(1, .01, 1, .41);
}
.cardHoverSide {
border: none;
background: #eee;
color: #444;
width: inherit;
height: inherit;
position: absolute;
bottom: -17em;
}
.cardHoverSide p span:hover {
color: red;
}
h1, h2, p {
margin: .5em .3em;
padding: 0;
}
I want the hover state of each nested element to be fired anytime the mouse is over that element. For instance when you are moving the mouse in the empty space of the nested card it doesn't seem to always trigger the hover state consistently.
The nested span tag also has some issues... don't know if I've set up the CSS incorrectly/not with best practices - or if I need to be using JS to trigger that.
Thanks for reading! All help is greatly appreciated.
Edit Updated fiddle
I'm specifically interested in when the mouse is stationary after initiating the transition - it seems on chrome the hover state does not fire on the child elements (so in the fiddle the p tag or nested panel don't change states). I've been able to consistently repeat this behavior on the updated fiddle.
as you can see here http://jsfiddle.net/Ec8kN/ , my css circles are not working properly. Initially I only had one class .circle that I used several times to have multiple circles and it was working fine. I then decided to name each circle differently (i.e. circle-1, circle-2, circle-3) to get a better control with JS at a later stage.
That's where the issues started. Now that I renamed them circle-1, circle-2, etc they won't display correctly anymore. What could be the issue? Many thanks
<div class="circle-1 circlebackground circle_5px_marging">
<p>Créativité</p>
<div class="innercircle">
<p>Le fdfd stimule la dfdsfd du fdfds en le dfdfd à réinventer sa dfdsf de la dfds dfs et donc les fdsfs qu’il peut y fdssf.</p>
</div>
</div>
<div class="circle-2 circlebackground circle_5px_marging">
<p>Circle 2</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
<div class="circle-3 circlebackground">
<p>Circle 3</p>
<div class="innercircle">
<p>by Angela</p>
</div>
</div>
.circle_5px_marging {
margin-right: 30px;
}
.circle-1, .circle-2, .circle-3 {
position: relative;
float: left;
margin-bottom: 10px;
width: 220px;
height: 220px;
border-radius: 50%;
box-shadow: inset 0 0 0 0px rgba(255, 255, 255, 0.6), 0 1px 2px rgba(0, 0, 0, 0.1);
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
}
.circlebackground {
border:1px solid #2970AE;
background: #FFF;
}
.innercircle {
position: absolute;
width: inherit;
height: inherit;
border-radius: 50%;
background: #2970AE;
opacity: 0;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
-ms-transition: all 0.4s ease-in-out;
-o-transition: all 0.4s ease-in-out;
transition: all 0.4s ease-in-out;
-webkit-transform: scale(0);
-moz-transform: scale(0);
-ms-transform: scale(0);
-o-transform: scale(0);
transform: scale(0);
-webkit-backface-visibility: hidden;
}
.circle-1, .circle-2, .circle-3 p {
position: absolute;
top: 50%;
left: 50%;
margin: 0;
color: #2970AE;
letter-spacing: 1px;
font-weight: 700;
font-size: 14px;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.innercircle p {
position: absolute;
top: 50%;
left: 50%;
margin: 0;
color:#fff;
text-align: center;
font-weight: 300;
font-size: 10px;
opacity: 1;
-webkit-transition: all 1s ease-in-out 0.4s;
-moz-transition: all 1s ease-in-out 0.4s;
-ms-transition: all 1s ease-in-out 0.4s;
-o-transition: all 1s ease-in-out 0.4s;
transition: all 1s ease-in-out 0.4s;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.circle-1:hover {
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 1px 2px rgba(0, 0, 0, 0.1);
}
.circle-1:hover .innercircle {
opacity: 1;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1);
}
.circle-1:hover .innercircle p {
opacity: 1;
}
.clear {
clear: both;
}
Change .circle-1, .circle-2, .circle-3 p to .circle-1 p, .circle-2 p, .circle-3 p. It should work.
As it is now, the properties set under this rule will apply to elements with class as circle-1, circle-2 and the p tag under all elements with class as circle-3.
Fiddle Demo
You need to fix one selector:
.circle-1 p, .circle-2 p, .circle-3 p
Instead of:
.circle-1, .circle-2, .circle-3 p
Like I've written on the previous question of yours, the current selector is applied on .circle-1, .circle-2, and all paragraphs inside .circle-3. If you want it to be applied on every paragraph inside those classes you have to address p on each class separately.
jsFiddle Demo
I can only advise you to restore the common circle class, then add a different id to each circle (e.g. id="circle1") and use the # CSS operator (e.g. #circle1) to customize each circle. That way you can tidy up your CSS code a little bit. For example, your first circle:
<div id="circle-1" class="circle circlebackground circle_5px_marging">
<p>Créativité</p>
<div class="innercircle">
<p>Le fdfd stimule la dfdsfd du fdfds en le dfdfd à réinventer sa dfdsf de la dfds dfs et donc les fdsfs qu’il peut y fdssf.</p>
</div>
Look here.
Going back to one css class for your circles is the way to go. If you need to distinguish them in Javascript then add an id to each circle.
From W3 Schools: The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements.
Furthermore accessing Ids in Javascript is easier and faster than accessing classes. Even though frameworks make it easy and browser are pretty fast nowadays.
I have found the problem.
There is no syntax error but the Circle 1 you have gets overlapped by Circle-2 which you can see by hiding circle 2.
So you just need to change the position of the circle 2.