简体   繁体   English

CSS3过渡只是规模

[英]CSS3 transition only scale

A simple question. 一个简单的问题。

When I hover the element, element should be scale. 当我悬停元素时,元素应该是缩放。 Working fine. 工作正常。 Problem is I have some background colors also applying. 问题是我有一些背景颜色也适用。 I want to get rid of this background transition. 我想摆脱这种背景转变。

Following is my code. 以下是我的代码。

.scale{
  -webkit-transition: all .2s ease-in-out;
  -moz-transition: all .2s ease-in-out;
  -o-transition: all .2s ease-in-out;
  transition: all .2s ease-in-out;
}

.scale:hover{
  -webkit-transform: scale(1.1);
  -moz-transform: scale(1.1);
  -o-transform: scale(1.1);
  transform: scale(1.1);
}

I have changes the transition-property to width, height, top, right, bottom, left 我已将过渡属性更改为width, height, top, right, bottom, left

My pen http://codepen.io/anon/pen/yAGBj 我的笔http://codepen.io/anon/pen/yAGBj

Change your transition to only affect the desired CSS properties rather than all : 将您的transition更改为仅影响所需的CSS属性而不是all

transition: transform .2s ease-in-out;

CodePen demo . CodePen演示

As I mentioned in the comment above, just add the background:red in your scale:hover class. 正如我在上面的评论中提到的,只需在您的scale:hover添加background:red scale:hover类。

.scale:hover{
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
background:red;
}

DEMO DEMO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM