Separate 2 div's with slope line

前端 未结 6 1831
栀梦
栀梦 2020-12-20 19:52

i want to seperate 2 floating div\'s with a slope line, they got different background colors.

Example here:

6条回答
  •  感情败类
    2020-12-20 20:42

    I would personally avoid using transforms and use the border property instead. This seems much cleaner to me (and also works in IE8).

    Example: http://jsfiddle.net/F6DgA/5/

    Note: To make sure the content inside the divs doesn't float on top of the edge, add something like * { box-sizing:border-box; } and then a padding left/right to the divs.

    The CSS:

    #wrap {
        width:300px;
        height:100px;
        margin:0 auto;
        position:relative;
    }
    
    #wrap div {
        position:relative;
        height:100%;
        float:left;
    }
    
    #one {
        background:#333;
        width:calc(50% + 15px);
    }
    
    #one:after {
        content:"";
        position:absolute;
        right:0;
        border-right:30px solid black;
        border-top:100px solid transparent;
    }
    
    #two {
        background:#000;
        width:calc(50% - 15px);
    }
    

提交回复
热议问题