我有这个垂直的CSS Carousel工作正常。
var carousel = $(".carousel"),
currdeg = 0;
$(".next").on("click", { d: "n" }, rotate);
$(".prev").on("click", { d: "p" }, rotate);
function rotate(e){
if(e.data.d=="n"){
currdeg = currdeg - 60;
}
if(e.data.d=="p"){
currdeg = currdeg + 60;
}
carousel.css({
"-webkit-transform": "rotateX("+currdeg+"deg)",
"-moz-transform": "rotateX("+currdeg+"deg)",
"-o-transform": "rotateX("+currdeg+"deg)",
"transform": "rotateX("+currdeg+"deg)"
});
}
body {
background: #333;
padding: 70px 0;
font: 15px/20px Arial, sans-serif;
}
.transformer {
transform: translateY(150px);
}
.container {
margin: 0 auto;
width: 250px;
height: 200px;
position: relative;
perspective: 1000px;
}
.carousel {
height: 100%;
width: 100%;
position: absolute;
transform-style: preserve-3d;
transition: transform 1s;
}
.item {
display: block;
position: absolute;
background: #000;
width: 250px;
height: 200px;
line-height: 200px;
font-size: 5em;
text-align: center;
color: #FFF;
opacity: 0.95;
border-radius: 10px;
}
.a {
transform: rotateX(0deg) translateZ(250px);
background: #ed1c24;
}
.b {
transform: rotateX(60deg) translateZ(250px);
background: #0072bc;
}
.c {
transform: rotateX(120deg) translateZ(250px);
background: #39b54a;
}
.d {
transform: rotateX(180deg) translateZ(250px);
background: #f26522;
}
.e {
transform: rotateX(240deg) translateZ(250px);
background: #630460;
}
.f {
transform: rotateX(300deg) translateZ(250px);
background: #8c6239;
}
.next, .prev {
color: #444;
position: absolute;
top: 100px;
padding: 1em 2em;
cursor: pointer;
background: #CCC;
border-radius: 5px;
border-top: 1px solid #FFF;
box-shadow: 0 5px 0 #999;
transition: box-shadow 0.1s, top 0.1s;
}
.next:hover, .prev:hover { color: #000; }
.next:active, .prev:active {
top: 104px;
box-shadow: 0 1px 0 #999;
}
.next { right: 1em; }
.prev { left: 1em; }
<script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div class="transformer">
<div class="container">
<div class="carousel">
<div class="item a">A</div>
<div class="item b">B</div>
<div class="item c">C</div>
<div class="item d">D</div>
<div class="item e">E</div>
<div class="item f">F</div>
</div>
</div>
<div class="next">Next</div>
<div class="prev">Prev</div>
</div>
我只需要一些视觉调整的帮助。 我怎样才能淡出元素,这样只有视图中的div(前面) 100%可见。其他元素应从100%淡化到0%,具体取决于 他们离前线有多远。
有什么想法吗?非常感谢你。