我正在尝试创建一个动画,其中图像将被包裹在圆柱体或瓶子周围。
我正在使用CSS3,它在某种程度上起作用。但我无法找到一种方法来带来圆筒的下半部分!它的顶部是我需要的,下半部分需要与顶部位相同。
我已经制作了一个jsFiddle但是这个页面在jsFiddle上并不像它,因为它没有显示3D。请从此处获取代码并在本地空白HTML页面上进行尝试,以便您知道我在说什么:http://jsfiddle.net/crf121359/Kk7AB/
我只需要让下半部分(底部圆圈)与上半部分完全相同。
我确实玩过X / Y值,似乎没什么用!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="wrap an image around a 3D revolving cylinder using only HTML and CSS3 3D, tutorial" />
<meta name="keywords" content="panorama how to wrap image around cylinder CSS3 3D tutorial wrapping a picture around a cylinder " />
<meta name="copyright" content="(c) 2011 - 2012" />
<meta name="author" content="Preston E Hall, director@baloziproductions.com" />
<title>Image Wrapped Around Spinning Cylinder Using Pure CSS3 3D</title>
<style type="text/css" media="screen">
body {background:#000;
color:rgb(236,132,57)}
h1 {font:small-caps 167% Arial,Helvetica,sans-serif}
#container {
text-align:center;
margin:0 auto;
top:450px;
width:550px;
-moz-perspective: 900px;
-webkit-perspective: 900}
#container:hover * {
-moz-animation-play-state:paused;
-webkit-animation-play-state:paused}
#frame {width: 33px;
-moz-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d; /* translate must be last */
-moz-transform: rotateX(10deg) rotateY(0deg) rotateZ(0deg) translate3d(125px,70px,50px);
-webkit-transform: rotateX(10deg) rotateY(0deg) rotateZ(0deg) translate3d(125px,70px,50px);}
.strip {-moz-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
-moz-animation: spin 15s infinite linear;
-webkit-animation: spin 15s infinite linear}
.strip div {
position: absolute;
background: url(http://thumbp2-ir2.thumb.mail.yahoo.com/tn?sid=24769798665600007&mid=AKoo5C4AABDQUg0%2FRwAAAHNDk2E&midoffset=2_0_0_1_7182251&partid=1.2&f=1726&fid=Inbox&w=614&h=503); /* background image is 792px 320px, try with green-hills or thailand-sunrise.jpg */
background-repeat:no-repeat;
border: solid rgb(145,87,0);
border-width: thin 10px;
height:320px;
width:33px;
opacity: 100;
}
.strip .a {background-position: 0 0;
-moz-transform: rotateY(0deg) translateZ(124px);
-webkit-transform: rotateY(0deg) translateZ(124px)}
.strip .b {background-position: 759px 0;
-moz-transform: rotateY(0deg) translateZ(124px);
-webkit-transform: rotateY(0deg) translateZ(124px)}
.strip .c {background-position: 726px 0;
-moz-transform: rotateY(30deg) translateZ(124px);
-webkit-transform: rotateY(30deg) translateZ(124px)}
.strip .d {background-position: 693px 0;
-moz-transform: rotateY(45deg) translateZ(124px);
-webkit-transform: rotateY(45deg) translateZ(124px)}
.strip .e {background-position: 660px 0;
-moz-transform: rotateY(60deg) translateZ(124px);
-webkit-transform: rotateY(60deg) translateZ(124px)}
.strip .f {background-position: 627px 0;
-moz-transform: rotateY(75deg) translateZ(124px);
-webkit-transform: rotateY(75deg) translateZ(124px)}
.strip .g {background-position: 594px 0;
-moz-transform: rotateY(90deg) translateZ(124px);
-webkit-transform: rotateY(90deg) translateZ(124px)}
.strip .h {background-position: 561px 0;
-moz-transform: rotateY(105deg) translateZ(124px);
-webkit-transform: rotateY(105deg) translateZ(124px)}
.strip .i {background-position: 528px 0;
-moz-transform: rotateY(120deg) translateZ(124px);
-webkit-transform: rotateY(120deg) translateZ(124px)}
.strip .j {background-position: 495px 0;
-moz-transform: rotateY(135deg) translateZ(124px);
-webkit-transform: rotateY(135deg) translateZ(124px)}
.strip .k {background-position: 462px 0;
-moz-transform: rotateY(150deg) translateZ(124px);
-webkit-transform: rotateY(150deg) translateZ(124px)}
.strip .l {background-position: 429px 0;
-moz-transform: rotateY(165deg) translateZ(124px);
-webkit-transform: rotateY(165deg) translateZ(124px)}
.strip .m {background-position: 396px 0;
-moz-transform: rotateY(180deg) translateZ(124px);
-webkit-transform: rotateY(180deg) translateZ(124px)}
.strip .n {background-position: 363px 0;
-moz-transform: rotateY(195deg) translateZ(124px);
-webkit-transform: rotateY(195deg) translateZ(124px)}
.strip .o {background-position: 330px 0;
-moz-transform: rotateY(210deg) translateZ(124px);
-webkit-transform: rotateY(210deg) translateZ(124px)}
.strip .p {background-position: 297px 0;
-moz-transform: rotateY(225deg) translateZ(124px);
-webkit-transform: rotateY(225deg) translateZ(124px)}
.strip .q {background-position: 264px 0;
-moz-transform: rotateY(240deg) translateZ(124px);
-webkit-transform: rotateY(240deg) translateZ(124px)}
.strip .r {background-position: 231px 0;
-moz-transform: rotateY(255deg) translateZ(124px);
-webkit-transform: rotateY(255deg) translateZ(124px)}
.strip .s {background-position: 198px 0;
-moz-transform: rotateY(270deg) translateZ(124px);
-webkit-transform: rotateY(270deg) translateZ(124px)}
.strip .t {background-position: 165px 0;
-moz-transform: rotateY(285deg) translateZ(124px);
-webkit-transform: rotateY(285deg) translateZ(124px)}
.strip .u {background-position: 132px 0;
-moz-transform: rotateY(300deg) translateZ(124px);
-webkit-transform: rotateY(300deg) translateZ(124px)}
.strip .v {background-position: 99px 0;
-moz-transform: rotateY(315deg) translateZ(124px);
-webkit-transform: rotateY(315deg) translateZ(124px)}
.strip .w {background-position: 66px 0;
-moz-transform: rotateY(330deg) translateZ(124px);
-webkit-transform: rotateY(330deg) translateZ(124px)}
.strip .x {background-position: 33px 0;
-moz-transform: rotateY(345deg) translateZ(124px);
-webkit-transform: rotateY(345deg) translateZ(124px)}
@-moz-keyframes spin {
from { -moz-transform: rotateY(0)}
to { -moz-transform: rotateY(-360deg)}}
@-webkit-keyframes spin {
from { -webkit-transform: rotateY(0)}
to { -webkit-transform: rotateY(-360deg)}}
</style>
</head>
<body>
<div id="container">
<h1>Image Wrapped Around A Spinning strip</h1>
<div id="frame">
<div class="strip">
<div class="a"></div>
<div class="b"></div>
<div class="c"></div>
<div class="d"></div>
<div class="e"></div>
<div class="f"></div>
<div class="g"></div>
<div class="h"></div>
<div class="i"></div>
<div class="j"></div>
<div class="k"></div>
<div class="l"></div>
<div class="m"></div>
<div class="n"></div>
<div class="o"></div>
<div class="p"></div>
<div class="q"></div>
<div class="r"></div>
<div class="s"></div>
<div class="t"></div>
<div class="u"></div>
<div class="v"></div>
<div class="w"></div>
<div class="d"></div>
</div>
</div>
</div>
</body>
</html>
提前致谢。
答案 0 :(得分:1)
好吧我在@ j08691给出的那个小提琴中玩了一点CSS。我想出了这个。
我真正改变的唯一事情是rotateX(10deg)
和-moz-transform
到-webkit-transform-
0deg
#frame {width: 33px;
-moz-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d; /* translate must be last */
-moz-transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate3d(125px,70px,50px);
-webkit-transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) translate3d(125px,70px,50px);}
当你将它倾斜10度时,为了使它看起来更“3D”,他们将底部向用户倾斜,使它看起来更接近它们。这反过来使屏幕底部更大。
答案 1 :(得分:0)
通过更改以下代码行来解决问题:
#container {
text-align:center;
margin:0 auto;
top:450px;
width:550px;
-moz-perspective: 2000px;
-webkit-perspective: 2000}