extjs 水平翻转html和css

bvhaajcl  于 2022-11-04  发布在  其他
关注(0)|答案(3)|浏览(166)

我正在尝试实现一个功能,我需要有两个树,一个挨着另一个,看起来像镜子。请看图片:

重点是我找到了水平翻转它的方法,但文本也被颠倒了。我不能做的是颠倒树,让文本保持原样。
下面是我所做的:http://jsfiddle.net/lontivero/R24mA/
基本上,下列类别会套用至html主体:

.flip-horizontal {
    -moz-transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
    -o-transform: scaleX(-1);
    transform: scaleX(-1);
    -ms-filter: fliph; /*IE*/
    filter: fliph; /*IE*/
}

HTML代码:

<body class="flip-horizontal"></body>

而JS:

Ext.create('Ext.grid.Panel', {
    title: 'Simpsons',
    height: 200,
    width: 400,
    // more and more code. SO forces me to paste js code ;(
    renderTo: Ext.getBody()
});
xurqigkl

xurqigkl1#

你的小提琴已经有了答案的开头--在文本上做第二次翻转。有一个额外的,阻止了第二条规则的解析。
I've updated the fiddle以包括标题元素,并将它们设置为inline-block,因为inline elements can't be transformed

.flip-horizontal, .x-grid-cell-inner, .x-column-header-text, .x-panel-header-text {
    -moz-transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
    -o-transform: scaleX(-1);
    transform: scaleX(-1);
    -ms-filter: fliph; /*IE*/
    filter: fliph; /*IE*/
}

.x-column-header-text, .x-panel-header-text {
    display: inline-block;
}
ct2axkht

ct2axkht2#

我试过这个,效果很好!
HTML程式码:

<div class="flip-container" ontouchstart="this.classList.toggle('hover');">
    <div class="flipper">
        <div class="front">
            <!-- Front content -->
        </div>

        <div class="back">
            <!-- Back content -->
        </div>
    </div>
</div>

CSS:

/* Flip the pane when hovered */
.flip-container:hover .flipper, .flip-container.hover .flipper {
    transform: rotateY(180deg);
}

.flip-container, .front, .back {
    width: 320px;
    height: 480px;
}

/* Flip speed goes here */
.flipper {
    transition: 0.6s;
    transform-style: preserve-3d;

    position: relative;
}

/* Hide back of pane during swap */
.front, .back {
    backface-visibility: hidden;

    position: absolute;
    top: 0;
    left: 0;
}

/* Front pane, placed above back */
.front {
    z-index: 2;

    /* For Firefox 31 */
    transform: rotateY(0deg);
}

/* Back, initially hidden pane */
.back {
    transform: rotateY(180deg);
}

我在一个Bootstrap col-sm-*中使用了这个,效果也很好:

<div class="col-sm-4 flip-container" ontouchstart="this.classList.toggle('hover');">
    <div class="content-box flipper">
        <div class="content-box-front">
            <span class="glyphicon glyphicon-envelope content-box-icon"></span>
            <h4>Share your emotions</h4>
        </div>
        <div class="content-box-back">
            <p>Share emotions with friends, family and teammates.</p>
            <button>Read more</button>
        </div>
    </div>
</div>

“CSS:

.content-box {
    position: relative;
    text-align: center;
    height: 105px;
    width: 100%;
}

.content-box-icon {
    font-size: 30px;
    width: 60px;
    height: 60px;
    line-height: 60px;
    border-radius: 50%;
    text-align: center;
    display: block;
    margin: 5px auto 15px auto;
    color: #fff;
    float: none; 
    background:#25acfd                     
}

.content-box-front
{
    z-index: 2;

    /* For Firefox 31 */
    transform: rotateY(0deg);

    backface-visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 105px;
}

.content-box-back {
    transform: rotateY(180deg);
    backface-visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 105px;
}

/* Entire container, keeps perspective */

/* Flip the pane when hovered */
.flip-container:hover .flipper, .flip-container.hover .flipper {
    transform: rotateY(180deg);
}

/* Flip speed goes here */
.flipper {
    transition: 0.6s;
    transform-style: preserve-3d;
    position: relative;
}
m1m5dgzv

m1m5dgzv3#

下面是example

/* Entire text flipped around */
div {
  -webkit-transform:rotateY(180deg);
  -moz-transform:rotateY(180deg);
  -o-transform:rotateY(180deg);
  -ms-transform:rotateY(180deg);
}

相关问题