【问题标题】:Trapezium without border-color不带边框颜色的梯形
【发布时间】:2013-11-04 06:33:49
【问题描述】:

我想在 css 中创建两个梯形。我不能使用边框颜色,因为我想给形状背景图像。一切都应该解释图片。在两个 div 中都会放一些文本。

能不能用html、css、js、svg 就是不知道怎么用。

http://iv.pl/images/82062332573614452824.jpg http://iv.pl/images/32788252576166741527.jpg

【问题讨论】:

    标签: html css svg shapes


    【解决方案1】:

    您可以通过使用 :after 伪元素在纯 CSS 中实现这一点。

    基本上,我创建了两个矩形。然后我在右侧矩形上覆盖了一个三角形,该三角形是通过:after 伪元素添加的。

    jsFiddle example - 看起来一样

    HTML

    <div id="wrap">
        <div id="one"></div>
        <div id="two"></div>
    </div>
    

    CSS

    div {
        float: left;
        position: relative;
        height: 100px;
    }
    
    #one {
        background: green;
        width: 130px;
    }
    
    #two {
        background: red;
        width: 70px;
    }
    
    #two:after {
        content: "\A";
        border-top: 100px solid transparent;
        border-bottom: 60px solid transparent;
        border-right: 45px solid red;
        position: absolute;
        left: -45px;
    }
    
    #wrap {
        overflow: hidden;
    }
    

    【讨论】:

    • 我放了两张图片而不是两种颜色(背景尺寸:封面)。另外,我还要加上#left:hover和#right:hover与另外两张照片。
    • @user2950873 你可以这样做,我为你提供了编码。
    • 如何更改border-right:图片上的45px纯红色?
    • @user2950873 制作另一个解决方案。给我一分钟
    • 我觉得会很好。 '会检查并让你知道。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-17
    • 1970-01-01
    • 2017-06-20
    • 1970-01-01
    • 2012-10-26
    • 2013-11-03
    • 2021-02-06
    相关资源
    最近更新 更多