【问题标题】:3d image gallery made with css not responsive用 css 制作的 3d 图像库没有响应
【发布时间】:2017-01-04 07:50:36
【问题描述】:

我的网站 kaloraat.com 中有 3D 旋转图片库。它看起来很棒,但对移动设备的响应速度不够快。尺寸不会缩小,如果用户使用触摸屏设备向右滑动,它会超出身体区域。

我从 codepen 获取代码,只是谷歌 3d 图像库 codepen,我试图粘贴链接,但在这里出现错误,是 Stack Overflow 的新手。

有什么让它响应的想法吗?我将它包裹在引导容器流体、jumbotron 等中,但没有成功。

html

<h1>3d images gallery</h1>
  <div class="container">
        <div id="carousel">
            <figure><img src="http://lorempixel.com/186/116/nature/1" alt=""></figure>
            <figure><img src="http://lorempixel.com/186/116/nature/2" alt=""></figure>
            <figure><img src="http://lorempixel.com/186/116/nature/3" alt=""></figure>
            <figure><img src="http://lorempixel.com/186/116/nature/4" alt=""></figure>
            <figure><img src="http://lorempixel.com/186/116/nature/5" alt=""></figure>
            <figure><img src="http://lorempixel.com/186/116/nature/6" alt=""></figure>
            <figure><img src="http://lorempixel.com/186/116/nature/7" alt=""></figure>
            <figure><img src="http://lorempixel.com/186/116/nature/8" alt=""></figure>
            <figure><img src="http://lorempixel.com/186/116/people/9" alt=""></figure>
        </div>
    </div>

css

@import url(http://fonts.googleapis.com/css?family=Anaheim);

*{
  margin: 0;
  padding: 0;
  outline: none;
  border: none;
    box-sizing: border-box;
}
*:before,
*:after{
    box-sizing: border-box;
}
html,
body{
    min-height: 100%;
}
body{
    background-image: radial-gradient(mintcream 0%, lightgray 100%);
}
h1{
    display: table;
    margin: 5% auto 0;
    text-transform: uppercase;
    font-family: 'Anaheim', sans-serif;
    font-size: 4em;
    font-weight: 400;
    text-shadow: 0 1px white, 0 2px black;
}
.container{
    margin: 4% auto;
    width: 210px;
    height: 140px;
    position: relative;
    perspective: 1000px;
}
#carousel{
    width: 100%;
    height: 100%;
    position: absolute;
    transform-style: preserve-3d;
    animation: rotation 20s infinite linear;
}
#carousel:hover{
    animation-play-state: paused;
}
#carousel figure{
    display: block;
    position: absolute;
    width: 186px;
    height: 116px;
    left: 10px;
    top: 10px;
    background: black;
    overflow: hidden;
    border: solid 5px black;
}
#carousel figure:nth-child(1){transform: rotateY(0deg) translateZ(288px);}
#carousel figure:nth-child(2) { transform: rotateY(40deg) translateZ(288px);}
#carousel figure:nth-child(3) { transform: rotateY(80deg) translateZ(288px);}
#carousel figure:nth-child(4) { transform: rotateY(120deg) translateZ(288px);}
#carousel figure:nth-child(5) { transform: rotateY(160deg) translateZ(288px);}
#carousel figure:nth-child(6) { transform: rotateY(200deg) translateZ(288px);}
#carousel figure:nth-child(7) { transform: rotateY(240deg) translateZ(288px);}
#carousel figure:nth-child(8) { transform: rotateY(280deg) translateZ(288px);}
#carousel figure:nth-child(9) { transform: rotateY(320deg) translateZ(288px);}

img{
    -webkit-filter: grayscale(1);
    cursor: pointer;
    transition: all .5s ease;
}
img:hover{
    -webkit-filter: grayscale(0);
  transform: scale(1.2,1.2);
}

@keyframes rotation{
    from{
        transform: rotateY(0deg);
    }
    to{
        transform: rotateY(360deg);
    }
}

任何帮助将不胜感激。

【问题讨论】:

    标签: css image 3d gallery responsive


    【解决方案1】:

    您可以尝试将 transform: scale() 与媒体查询一起使用以获取较小的屏幕。

    @media (max-width: 600px) {
      .project-magic {
        transform: scale(0.6);
      }
    }
    

    【讨论】:

    • 你太棒了,你的回答为我节省了很多时间:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-10
    • 2019-02-17
    • 2016-02-02
    • 1970-01-01
    • 2014-08-15
    • 2012-11-17
    相关资源
    最近更新 更多