简体   繁体   English

异常的CSS过渡行为。 您可以禁用特定参数吗?

[英]Unusual CSS Transition behaviour. Can you disable specific parameters?

I'm using a transition on elements of a table in order to provide a pretty cool border effect, this all works fine. 我在表格的元素上使用过渡效果,以提供漂亮的边框效果,这一切都很好。

The problem I'm getting is that occasionally (not every time) on page refresh each individual box will transition in as if all of the variables are blank and will resize from (presumably) height 0 width 0 to height 250 and width 250. It looks incredibly ugly and kinda ruins the whole effect of the site. 我遇到的问题是,页面刷新时偶尔(并非每次)刷新每个单独的框,就像所有变量都是空白一样,并且将其大小从(大概)高度0宽度0调整为高度250和宽度250。看起来非常丑陋,有点破坏了网站的整体效果。

My presumption is that, for whatever reason, the transition all catch is misinterpreting some variables as being null or zero, then transitioning from that to 250. However I can't test this as, as far as I know, you cannot make an exception for width and height. 我的推测是,无论出于何种原因,所有捕获的过渡都将某些变量误解为null或零,然后从该变量过渡为250。但是据我所知,我无法对此进行测试,因此您无法例外用于宽度和高度。

I've tried manually setting a transition for the six important parameters (outline, outline-offset, color, background-image, background-position, background-size) but this simply results in the transition not working correctly, the background image simply snaps on and off with no transitions at all... so something must be going on. 我尝试为六个重要参数(轮廓,轮廓偏移,颜色,背景图像,背景位置,背景尺寸)手动设置过渡,但这只会导致过渡无法正常工作,背景图像会突然捕捉开启和关闭,完全没有任何过渡...因此必须进行一些操作。

Here is the code; 这是代码;

#portfolio-table td{
width: 250px;
height: 250px;
min-width: 250px;
min-height: 250px;

box-shadow: inset 0 0 50px 20px rgba(0,0,0,.35);

outline: 3px solid black;
outline-offset: -3px;

color: transparent !important; /* Makes text invisible until hover */

background-position:center;
background-repeat: no-repeat;
background-size: 100%;

text-align: center;

transition: all 1.5s ease-in-out;
    }

#portfolio-table td:hover{
outline: 10px solid white;
outline-offset: -10px;

color: black !important; /* Makes text visible */

box-shadow: inset 0 0 25px 10px rgba(0,0,0,.35);

background-image: url(../images/bg.jpg) !important;
background-repeat: no-repeat;
background-size: 100%;

cursor: pointer;

transition: all 0.5s ease-in-out;
    }

It might be important to note that background-image is being set by CSS per-cell. 重要的是要注意,背景图像是由CSS每单元设置的。 Heres the code for that; 继承人的代码;

#portfolio-table #project1{
background-image: url(../images/project7.jpg);
     }

There is a lot of repetition in the hover (for example the no-repeat and background-size) in an attempt to prevent this unusual behaviour. 为了防止这种异常行为,悬停中有很多重复(例如,不重复和背景大小)。

As you can see a min-size is set for both width and height, but it still transitions in as if it was 0. 如您所见,为宽度和高度都设置了最小尺寸,但是它仍然过渡为0。

This is a link to a live example; 是一个实时示例的链接; if you spam refresh you should notice the effect. 如果您刷新垃圾邮件,则应注意效果。

You use 你用

box-shadow: inset 0 0 25px 10px rgba(0,0,0,.35);

I have had this problem before and i solved it with changing the .35 to 0.35 我之前遇到过这个问题,我通过将.35更改为0.35来解决了

I have changed the transition to 我已将过渡更改为

#portfolio-table td{

    ... 
transition: outline, outline-offset, color, box-shadow, background-image 1.5s ease-in-out;
}

and it works ok for me. 对我来说还可以。

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

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