CodeLab
Show Output
 
xxxxxxxxxx
48
 
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="utf-8">
5
<title>Example of CSS3 flex Property Animation</title>
6
<style>
7
.flex-container {
8
    width: 300px;
9
    height: 200px;
10
    font-size: 32px;
11
    border: 1px solid black;
12
    display: -webkit-flex; /* Safari */     
13
    display: flex; /* Standard syntax */
14
}
15
.flex-container div {       
16
    -webkit-flex: 1; /* Safari */
17
        -ms-flex: 1; /* IE 10 */
18
            flex: 1; /* Standard syntax */
19
}
20
.item1 {
21
    background: #e84d51;
22
}
23
.item2 {
24
    background: #7ed636;
25
}
26
.animated {
27
    -webkit-animation: test 4s infinite; /* Chrome, Safari, Opera */
28
    animation: test 4s infinite;
29
}
30
/* Chrome, Safari, Opera */
31
@-webkit-keyframes test {
32
    50% {-webkit-flex: 3;}
33
}
34
/* Standard syntax */
35
@keyframes test {
36
    50% {flex: 3;}
37
}
38
</style>
39
</head>
40
<body>
41
    <p><strong>Warning:</strong> CSS Animations do not work in Internet Explorer 9 and earlier versions.</p>
42
    <p><strong>Note:</strong> All the individual columns properties i.e. flex-grow, flex-shrink and flex-basis are animatable in CSS. See the CSS <a href="https://www.appwang.com/css-reference/css3-flex-property.php" target="_top">flex</a> shorthand property for details.<p>
 

在微博、微信、公众号、小程序分享此示例。 如果您觉得有帮助,请给我们一个赞。