html旋转相册代码

html-css019

html旋转相册代码,第1张

旋转index文件代码:

3D旋转相册

*{

padding:0

margin:0

}

body,

html{

height:100%

}

/*背景图片在这里设置*/

body{

background-image:url("images/beijing.jpg")

background-size:100%100%

}

#box{

width:280px

height:400px

position:fixed

left:0

right:0

top:0

bottom:0

margin:auto

transform-style:preserve-3d

transform:rotateX(0deg)rotateY(0deg)

animation:go45slinearinfinite

}

#boximg{

width:280px

height:400px

position:absolute

left:0

top:0

}

#boximg:nth-child(1){

transform:rotateY(0deg)translateZ(650px)

}

#boximg:nth-child(2){

transform:rotateY(36deg)translateZ(650px)

}

#boximg:nth-child(3){

transform:rotateY(72deg)translateZ(650px)

}

#boximg:nth-child(4){

transform:rotateY(108deg)translateZ(650px)

}

#boximg:nth-child(5){

transform:rotateY(144deg)translateZ(650px)

}

#boximg:nth-child(6){

transform:rotateY(180deg)translateZ(650px)

}

#boximg:nth-child(7){

transform:rotateY(216deg)translateZ(650px)

}

#boximg:nth-child(8){

transform:rotateY(252deg)translateZ(650px)

}

#boximg:nth-child(9){

transform:rotateY(288deg)translateZ(650px)

}

#boximg:nth-child(10){

transform:rotateY(324deg)translateZ(650px)

}

@keyframesgo{

0%{

transform:rotateX(0deg)rotateY(0deg)

}

25%{

transform:rotateX(20deg)rotateY(180deg)

}

50%{

transform:rotateX(0deg)rotateY(360deg)

}

75%{

transform:rotateX(-20deg)rotateY(540deg)

}

100%{

transform:rotateX(0deg)rotateY(720deg)

}

}

images/1.jpg

images/2.jpg

images/3.jpg

images/4.jpg

images/5.jpg

images/6.jpg

images/7.jpg

images/8.jpg

images/9.jpg

images/10.jpg

html相册就是把一组图片放到一个固定位置轮番滚动查看,一般是类似于qq相册的功能。

代码如下:

<script language="javascript">

//定义img图库

var img = ["","images/1.gif","images/2.gif","images/3.gif","images/4.gif"]//最前面留一个空白位置

//轮番显示

function show(op){

if(Number(op)){

// 取得对应的图片

document.getElementById("img1").src=img[op]

}

}

</script>

//设置图片显示样式

<style type="text/css">

li{

float:left

height:15px

background-color:#FF66FF

border:1px #00FFFF dotted

line-height:15px

}

a{

color:#00FFFF

text-decoration:none

}

</style>

以下是html代码,设置一个img控件,长和宽都是50个像素

<img src="images/1.gif" id="img1" width="50" height="50" />

<ul style="list-style-type:nonewidth:200px">

<li><a href="#" onclick="show(1)">1</a></li><!--点击显示第一张图-->

<li><a href="#" onclick="show(2)">2</a></li><!--点击显示第二张图-->

<li><a href="#" onclick="show(3)">3</a></li><!--点击显示第三张图-->

<li><a href="#" onclick="show(4)">4</a></li><!--点击显示第四张图-->

</ul>

以下是代码:

<!DOCTYPE html>

<html>

<head>

<title>transform-style实现Div的3D旋转-柯乐义</title>

<style>

*{font-size: 24pxcolor: #00ff00padding:0margin:0}

#container {

position: relative

height: 300px

width: 300px

-webkit-perspective: 500

margin-top: 200px

margin-right: auto

margin-left: auto

}

#parent-keleyi-com {

margin: 10px

width: 280px

height: 280px

background-color: #666

opacity: 0.3

-webkit-transform-style: preserve-3d

-webkit-animation: spin 15s infinite linear

}

#parent-keleyi-com >div {

position: absolute

top: 40px

left: 40px

width: 280px

height: 200px

padding: 10px

-webkit-box-sizing: border-box

}

#parent-keleyi-com >:first-child {

background-color: #000

-webkit-transform: translateZ(-100px) rotateY(45deg)

}

#parent-keleyi-com >:last-child {

background-color: #333

-webkit-transform: translateZ(50px) rotateX(20deg)

-webkit-transform-origin: 50% top

}

/*执行Y轴旋转360度动画*/

@-webkit-keyframes spin {

from {-webkit-transform: rotateY(0)}

to {-webkit-transform: rotateY(360deg)}

}

</style>

</head>

<body>

<div>请使用支持CSS3的浏览器<a href="http://keleyi.com/a/bjad/s89uo4t1.htm" target="_blank">原文</a></div>

<div id="container">

<div id="parent-keleyi-com">

<div><a href="/">柯乐义</a></div>

<div><a href="/">keleyi.com</a></div>

</div>

</div>

</body>

</html>