2013-06-04 49 views
0

喜的朋友是任何人知道如何使用CSS立方贝塞尔在HTML页面如何使用CSS过渡

我已经试过易于有效here
它无法正常工作。当页面加载时,帮助我缓解对div的影响。
这是我的CSS代码:

.container{width:100%;} 
.Innerdiv{width:50%;-webkit-transition: all 1s cubic-bezier(.42, 0, 1, 1); 
-moz-transition: all 1s cubic-bezier(.42, 0, 1, 1); padding:30px;} 

HTML是这里

<div class="container"> 
     <div class="Innerdiv"> 
      <h1> 
       What is Lorem Ipsum? 
      </h1> 
      <p> 
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
      </p> 
     </div> 
</div> 
+1

像这样:http://jsfiddle.net/YvR3L/过渡是让动画。但你需要改变它以动画形式..就像我用':hover'做的那样 –

+0

@Bondye如何在页面加载时轻松实现效果 –

回答

1

如果您希望在加载时发生转换,我怀疑您需要使用动画而不是转换。例如,如果你想内div来从100%到50%的收缩,而填充从0扩展到30像素,可以使用CSS这样的:

.container{ 
    width:100%; 
} 
.Innerdiv { 
    animation:shrinkInner 1s; 
    width:50%; 
    padding:30px; 
} 

@keyframes shrinkInner { 
    0% { 
    width:100%; 
    padding:0px; 
    } 
    100% { 
    width:50%; 
    padding:30px; 
    } 
} 

这仅仅是一个标准的CSS没有前缀 - 到支持webkit,您需要在必要时添加webkit前缀。

Fiddle example with prefixes included

+0

这就是我要感谢你soo多:) –

1

在这里简单的例子

div { 
    width: 100px; 
    -webkit-transition: width 2s; /* Safari */ 
    transition: width 2s; 
} 

div:hover { 
    width: 300px; 
} 

首先你提到的过渡到特定的类或ID,然后就可以设置过渡时,你想:hover :active什么你想要

过渡属性是四个过渡特性的缩写属性:

  1. 过渡PROPERT
  2. 过渡持续时间
  3. 过渡定时功能
  4. 过渡延迟

欲了解更多信息,请访问Here

在这里,我更新您的代码:DEMO

+0

我更新了用于转换的演示代码。 – Selvamani