请问,CSS3中怎样能让一个方框变成圆形之后,再以圆形的样子向前滚动

html-css012

请问,CSS3中怎样能让一个方框变成圆形之后,再以圆形的样子向前滚动,第1张

<!DOCTYPE html>

<html>

<head>

<style>

div

{

position: absolute

width:100px

height:100px

border-radius: 50%

background:red

animation:myfirst 5s

background:-moz-linear-gradient(top, red, rgba(0, 0, 255, 0.5))

background:-webkit-gradient(linear, 0 0, 0 bottom, from(#ff0000), to(rgba(0, 0, 255, 0.5)))

background:-o-linear-gradient(top, red, rgba(0, 0, 255, 0.5))

-moz-animation:myfirst 10s/* Firefox */

-webkit-animation:myfirst 10s/* Safari and Chrome */

-o-animation:myfirst 10s/* Opera */

}

@keyframes myfirst

{

from {left:0transform:rotate(0deg)}

to {left:1000pxtransform:rotate(360deg)}

}

@-webkit-keyframes myfirst /* Safari and Chrome */

{

from {left:0transform:rotate(0deg)}

to {left:1000pxtransform:rotate(360deg)}

}

</style>

</head>

<body style="position: relative">

<div></div>

</body>

</html>

您好,可以先画一个有立体感的球体,或者直接网上找个图片,然后给这个球体添加动画,选择强调里的陀螺旋,在效果选项里将重复次数自行设定,就可以实现让球体在地上滚动的效果。同时还可借助在图片上覆盖诸如半透明灰色和半透明白色的圆形形状来实现球体高光的视觉错觉,让滚动显得更加真实。当然,如果像前面的人所说的地球自转,我没想到实现办法。不过说回来,PPT本身只是个平面软件,所以只能靠一系列平面的视觉错觉来营造一种立体感。

不知道这合不合你意,,不过你这个要求,,可以搜索一下一些JQUERY效果,, <html>

 <head>

  <title>图片环形滚动</title>

<style>

html,body{background:#990000margin:0px }

#pics_3d{

position:absolute

height:300px

width:100% 

background:#000 

top:120px

border-bottom:20px solid #420000 

border-top:20px solid #420000 

}

img{

position:absolute

background:#eee 

left:0top:0

border:5px solid #00CCFF

}

</style>

 </head>

 <body>

 <div id="pics_3d">

  <img src="/jscss/demoimg/wall5.jpg" />  

  <img src="/jscss/demoimg/wall6.jpg" />  

  <img src="/jscss/demoimg/wall7.jpg" />  

 </div>

 </body>

<script >

Item=function(UI){

this.angle=0

this.UI=UI

this.update()

}

Item.ini={

axle_w:400,

axle_h:10,

cen_x:500,

cen_y:260

}

Item.prototype.update=function(){

var J=this.UI.style,C=Item.ini,W=C.axle_w,H=C.axle_h,X=C.cen_x,Y=C.cen_y

var angle=this.angle/180*Math.PI

var left=Math.cos(angle)*W+X

var top=Math.sin(angle)*H+Y

var A=this.angle>270?this.angle-360:this.angle

var size=360-Math.abs(90-A)*3

this.UI.width=Math.max(size,120)

var opacity=Math.max(10,size-180)

J.filter='alpha(opacity='+opacity+')'

J.opacity=opacity/100

J.left=(left-this.UI.offsetWidth/2)+'px'

top=(top-this.UI.offsetHeight)+'px'

J.top=top

J.zIndex=parseInt(size*100)

}

Nav_3D={

items:[],

dir:1,

index:0,

hover:false,

add:function(item){

this.items.push(item)

item.index=this.items.length-1

item.UI.onclick=function (){

var J=item.angle,M=Nav_3D

if(M.uping)return

if(J==90){

return alert('goto new url..')

}

M.wheel_90(item)

M.index=item.index

}

item.UI.onmouseover=function (){

if(item.angle==90){

Nav_3D.hover=true

clearTimeout(Nav_3D.autoTimer)

}

}

item.UI.onmouseout=function (){

if(item.angle==90){

Nav_3D.hover=false

Nav_3D.auto()

}

}

return this

},

wheel_90:function(hot){

if(this.uping)return

this.uping=true

var This=this

this.timer=setInterval(function (){

clearTimeout(This.autoTimer)

var A=hot.angle

This.dir=A<270&&A>90?-1:1

if(A==90){

clearInterval(This.timer)

This.uping=false

This.onEnd(hot)

}

if(A>270)A-=360

var set=Math.ceil(Math.abs((90-A)*0.1))

for (var i=0i<This.items.lengthi++ ) {

var J=This.items[i]

J.angle+= (set*This.dir)

J.update()

if(J.angle>360)J.angle-=360

if(J.angle<0)J.angle +=360

}

},15)

},

ready:function(){

var J=this.items,step=parseInt(360/J.length)

for (var i=0i<J.lengthi++) {J[i].angle=i*step+90}

this.wheel_90(this.items[0])

Nav_3D.prevHot=this.items[0].UI

Nav_3D.setHot()

},

setHot:function(isHot){

if(!this.prevHot)return

with(this.prevHot.style){

borderColor=isHot!==false?'#CC0000':'#00CCFF'

cursor=isHot!==false?'default':"pointer"

}

return this

},

auto:function(){

this.index--

if(this.index<0)this.index=this.items.length-1

var J=this.items[this.index]

this.setHot(false).prevHot=J.UI

this.setHot()

this.wheel_90(J)

},

onEnd:function(hot){

if(this.hover){

return setTimeout(function(){Nav_3D.onEnd()},100)

}

this.autoTimer=setTimeout(function(){Nav_3D.auto()},1500)

}

}

var imgs=document.getElementById("pics_3d").getElementsByTagName("IMG")

for (var i=0i<imgs.lengthi++ ) {

Nav_3D.add(new Item(imgs[i]))

}

Nav_3D.ready()

</script>

</html>