Need two slanted lines to form a point and act as a break for the page using CSS/HTML -
as can't upload images due reputation points here goes me trying explain it.
i have 2 div's need separated 2 slanted lines coming down towards each other forming point in middle. jsfiddle show mean.
i tried solution: http://jsfiddle.net/rz4b8/7/
however don't know how make responsive values set border-left-width property , works specific browser widths. below code;
.top-border { width: 100%; position: relative; left: 0; } .top-border-left { border-top-width: 30px; border-right-width: 0; border-bottom-width: 0; border-left-width: 800px; border-color: transparent transparent transparent #ffffff; float: left; } .top-border-left { border-style: solid solid inset solid; width: 0; height: 0; } .top-border-right { border-top-width: 0; border-right-width: 0; border-bottom-width: 30p x; border-left-width: 800px; border-color: transparent transparent #ffffff transparent; float: right; } .top-border-right { border-style: inset solid solid solid; width: 0; height: 0; }
jquery/css solution flexible triangular box
in simplest case, start html:
<div class="div1">text 1</div> <div class="top-border"> <div class="inner"></div> </div> <div class="div2">text 2</div>
and apply css:
.div1 { background: purple; height: 50px; } .div2 { background: red; height: 50px; } .top-border { overflow: hidden; } .top-border .inner { width: 0; height: 0; border-top: 50px solid lightgray; /* controls height of triangle */ border-left: 100px solid transparent; /* these default values reset jquery script */ border-right: 100px solid transparent; border-bottom: none; margin: 0 auto; }
and use following jquery script set correct border widths:
function settrianglewidth() { var basewidth = $(".top-border").width() / 2.0; $(".top-border .inner").css({ "border-left-width": basewidth + "px", "border-right-width": basewidth + "px" }); } $(window).resize(function(){settrianglewidth();}); $(document).ready(settrianglewidth())
demo fiddle at: http://jsfiddle.net/audetwebdesign/gs2pc/
this demonstrates basic concept. if want triangle overlap red text box, can use absolute positioning or negative margin, example:
.div2.ex2 { margin-top: -50px; position: relative; z-index: -1; padding-top: 50px; }
Comments
Post a Comment