html - 页面倾斜分隔线

标签 html css

我已经设法像这样从右到左做斜边形式:DEMO ,我现在要做的就是反转它,例如,如果这个从左边变大到右边变小,我需要它从右边变大到左边变小。基本上与我目前拥有的相反。

这是 HTML:

<div class="container">
            <section class="color"></section>
            <section class="col-3 ss-style-doublediagonal"></section>
        </div>

这是 CSS:

*,
*:after,
*::before {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.container {
    overflow: hidden;
    /* we don't want the pseudo-elements sticking out */
}

section {
    position: relative;
    padding: 10em 10%;
    background: red;
    color: #fff;
    text-align: center;
}

.color {
    background: red;
}

/*** Individual section styles and separators ***/

/* Common style for pseudo-elements */
section::before,
section::after {
    position: absolute;
    content: '';
    pointer-events: none;
}


/* Double Diagonal line */

.ss-style-doublediagonal {
    z-index: 1;
    padding-top: 6em;
    background: yellow;
}

.ss-style-doublediagonal::before,
.ss-style-doublediagonal::after {
    top: 0;
    left: -25%;
    z-index: -1;
    width: 150%;
    height: 75%;
    background: inherit;
    -webkit-transform: rotate(-2deg);
    transform: rotate(-2deg);
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
}

.ss-style-doublediagonal::before {
    height: 50%;
    background: blue;
    -webkit-transform: rotate(-3deg);
    transform: rotate(-3deg);
    -webkit-transform-origin: 3% 0;
    transform-origin: 3% 0;
}

非常感谢任何帮助。

最佳答案

我要告诉你我实际改变了什么。

Updated Fiddle

transform: rotate(2deg); /* was -2deg, rotating the other way now */
transform-origin: 100% 0; /* was 0 0, rotating from the other side */

和:

transform: rotate(3deg); /* was -3deg, rotating the other way */
transform-origin: 97% 0; /* was 3% 0, rotating from the other side */

关于html - 页面倾斜分隔线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25116840/

相关文章:

html - 高级 CSS 自定义

html - 图片只占一页

css - 特定 View 的不同标题样式

html - div 的 CSS 上边距

javascript - 全局变量在新的弹出窗口中未定义,而它们是预先定义的

javascript - 我可以告诉浏览器开始显示已经向下滚动的网页吗?

javascript - Chrome离线版不会使用cache.manifest

php - 实时 CSS 未生成

jQuery css ('padding' ) - Firefox 问题

javascript - jQuery UI - .toogleClass() 不工作