如何在列块中使用 html 使翻转框响应

发布于 2025-01-11 23:02:52 字数 4513 浏览 0 评论 0原文

我正在使用 Wordpress(Blocksy 主题),并创建了一个可在桌面上运行的三列翻页框,但不适用于移动设备。这段代码发生了两件事。我能够修复其中一个,但想知道为什么会发生这种情况(翻转卡与页面上的其他现有元素重叠。)我需要添加 3 个垫片,然后一切就合适了。

另一个问题(我不知道如何解决)是,在移动设备上,翻转卡相互重叠而不是堆叠,因此它们位于彼此后面。我希望在移动设备上查看时每个框都位于自己的行上。

我最初的想法是使用带有 html 的列块 - 每个翻页卡都有自己的图形 - 因此 3 列中的每一列都有 html 代码。 (我尝试制作自己的列和行,并将所有 html 放在一个列块中,但桌面上只显示一张翻转卡图像,而不是并排看到 3 张图像。当然,它没有无法在移动设备上使用。

如何使这些翻转卡片具有响应能力?另外,有没有办法使卡片在移动设备上触摸时翻转回来?(我注意到如果我触摸卡片上方,它会翻转回来,但不会)在卡上。)。谢谢

下面是代码(带有具体的图像和文本已删除):(就其价值而言,我知道 CSS 代码是多余的,但是当我尝试组合类时,我丢失了一些样式。例如,当我组合 .thefront-left-flipcard 时。thefront- center-flipcard 和 thefront-right-flipcard 对于除背景图像之外的所有样式,除其他外,卡片的正面几乎失去了所有宽度。)

跨 3 列的列块

列框 1:

<div class="maincontainer">

    <div class="thecard">

        <div class="thefront-left-flipcard">left title</div>

            <div class="theback">
                <ul>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
               </ul>
        </div>
    </div>
</div>

列框 2:

<div class="maincontainer">

    <div class="thecard">

        <div class="thefront-center-flipcard">center title</div>

            <div class="theback">
                <ul>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
               </ul>
        </div>
    </div>
</div>

列框 3:

<div class="maincontainer">

    <div class="thecard">

        <div class="thefront-right-flipcard">right title</div>

            <div class="theback">
                <ul>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
               </ul>
        </div>
    </div>
</div>
  




/*flipcard*/

/* THE MAINCONTAINER HOLDS EVERYTHING */
.maincontainer{
    position: absolute;
    height: 270px;
    width: 315px;
}
* THE CARD HOLDS THE FRONT AND BACK FACES */
.thecard{
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    transform-style: preserve-3d;
    transition: all 2s ease;
}


/* THE PSUEDO CLASS CONTROLS THE FLIP ON MOUSEOVER AND MOUSEOUT */
.thecard:hover {
    transform: rotateY(180deg);
}

/* THE FRONT FACE OF THE CARD, WHICH SHOWS BY DEFAULT */
.thefront-left-flipcard{
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    text-align: center;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    background-color: #6cbe45;
    background-image: url(https://..left.png);
    background-repeat:no-repeat;
    background-position: center;
    color: #6cbe45;
    font-size: 2.5em;
}

.thefront-center-flipcard{
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    text-align: center;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    background-color: #6cbe45;
    background-image: url(https://..center.png);
    background-repeat:no-repeat;
    background-position: center;
    color: #6cbe45;
    font-size: 2.5em;
}

.thefront-right-flipcard{
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    text-align: center;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    background-color: #6cbe45;
    background-image: url(https://..right.png);
    background-repeat:no-repeat;
    background-position: center;
    color: #6cbe45;
    font-size: 2.5em;
}

/* THE BACK FACE OF THE CARD, WHICH SHOWS ON MOUSEOVER */

.theback{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    background: #07486d;
    color: #e4c548;
    text-align: left;
    transform: rotateY(180deg);
}

I'm using Wordpress (Blocksy theme) and have created a three column flipbox that works on desktop, but not on mobile. Two things happen with this code. One I was able to fix, but wondered why it happened (the flip card overlapped other existing elements on the page.) I needed to add 3 spacers and then things fit.

The other issue (which I don't know how to fix) is that on mobile, the flip cards overlap each other instead of stacking, so that they are behind one another. I would like each box to be on its own line when viewed on mobile.

My initial idea was to use the column block with html - each flipcard has its own graphic - so each of the 3 columns has html code. (I tried to make my own columns and rows and put all the html in one column block, but then only one of the flip card images showed on desktop, instead of seeing the 3 images side by side. And, of course, it didn't work on mobile.

How do I make these flip cards responsive? And, separately, is there a way to make the card flip back on touch for mobile? (I noticed it will flip back if I touch above the card, but not on the card.). Thanks

Below is the code (with the specific images and text removed): (For what it's worth, I know the CSS code is redundant, but when I tried to combine classes, I lost some of the styling. For example, when I combined .thefront-left-flipcard. thefront-center-flipcard. and thefront-right-flipcard for all the styles except the background image, the front of the card lost almost all of its width, among other things.)

Column block with 3 columns across

Column box 1:

<div class="maincontainer">

    <div class="thecard">

        <div class="thefront-left-flipcard">left title</div>

            <div class="theback">
                <ul>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
               </ul>
        </div>
    </div>
</div>

Column box 2:

<div class="maincontainer">

    <div class="thecard">

        <div class="thefront-center-flipcard">center title</div>

            <div class="theback">
                <ul>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
               </ul>
        </div>
    </div>
</div>

Column box 3:

<div class="maincontainer">

    <div class="thecard">

        <div class="thefront-right-flipcard">right title</div>

            <div class="theback">
                <ul>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
                    <li>data</li>
               </ul>
        </div>
    </div>
</div>
  




/*flipcard*/

/* THE MAINCONTAINER HOLDS EVERYTHING */
.maincontainer{
    position: absolute;
    height: 270px;
    width: 315px;
}
* THE CARD HOLDS THE FRONT AND BACK FACES */
.thecard{
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    transform-style: preserve-3d;
    transition: all 2s ease;
}


/* THE PSUEDO CLASS CONTROLS THE FLIP ON MOUSEOVER AND MOUSEOUT */
.thecard:hover {
    transform: rotateY(180deg);
}

/* THE FRONT FACE OF THE CARD, WHICH SHOWS BY DEFAULT */
.thefront-left-flipcard{
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    text-align: center;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    background-color: #6cbe45;
    background-image: url(https://..left.png);
    background-repeat:no-repeat;
    background-position: center;
    color: #6cbe45;
    font-size: 2.5em;
}

.thefront-center-flipcard{
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    text-align: center;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    background-color: #6cbe45;
    background-image: url(https://..center.png);
    background-repeat:no-repeat;
    background-position: center;
    color: #6cbe45;
    font-size: 2.5em;
}

.thefront-right-flipcard{
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    text-align: center;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    background-color: #6cbe45;
    background-image: url(https://..right.png);
    background-repeat:no-repeat;
    background-position: center;
    color: #6cbe45;
    font-size: 2.5em;
}

/* THE BACK FACE OF THE CARD, WHICH SHOWS ON MOUSEOVER */

.theback{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    overflow: hidden;
    background: #07486d;
    color: #e4c548;
    text-align: left;
    transform: rotateY(180deg);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫嚣ゝ 2025-01-18 23:02:52

这很简单。看看下面这个例子:

.ea-flip-card-item {
    background-color: transparent;
    max-width: 300px;
    height: 300px;
    width: 100%;
    perspective: 1000px;
}
.ea-flip-card-item .ea-flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
}
.ea-flip-card-item:hover .ea-flip-card-inner {
    transform: rotateY(180deg);
}
.ea-flip-card-item .front, .ea-flip-card-item .back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}
.ea-flip-card-item .front {
    background-color: #ffa500;
    color: black;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.ea-flip-card-item .back {
    background-color: #ffffff;
    color: black;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
<div class="ea-flip-card-item">
            <div class="ea-flip-card-inner">
                <div class="front">
                    <div class="ua-flip-card-content text-center position-absolute d-flex align-items-center justify-content-center flex-wrap flex-column">
                            <h3>
                                I am from Front
                            </h3>
                            <p>
                              add description here
                            </p>
                    </div>
                </div>

                <div class="back">
                    <div class="ua-flip-card-content text-center position-absolute d-flex align-items-center justify-content-center flex-wrap flex-column">
                    <h1>
                                I am from Back</h1>
                                <p>Cool</p>
                    </div>
                </div>
            </div>
        </div>

It's very simple. Just loock at this example below:

.ea-flip-card-item {
    background-color: transparent;
    max-width: 300px;
    height: 300px;
    width: 100%;
    perspective: 1000px;
}
.ea-flip-card-item .ea-flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
}
.ea-flip-card-item:hover .ea-flip-card-inner {
    transform: rotateY(180deg);
}
.ea-flip-card-item .front, .ea-flip-card-item .back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}
.ea-flip-card-item .front {
    background-color: #ffa500;
    color: black;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.ea-flip-card-item .back {
    background-color: #ffffff;
    color: black;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
<div class="ea-flip-card-item">
            <div class="ea-flip-card-inner">
                <div class="front">
                    <div class="ua-flip-card-content text-center position-absolute d-flex align-items-center justify-content-center flex-wrap flex-column">
                            <h3>
                                I am from Front
                            </h3>
                            <p>
                              add description here
                            </p>
                    </div>
                </div>

                <div class="back">
                    <div class="ua-flip-card-content text-center position-absolute d-flex align-items-center justify-content-center flex-wrap flex-column">
                    <h1>
                                I am from Back</h1>
                                <p>Cool</p>
                    </div>
                </div>
            </div>
        </div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文