I'm trying to recreate this layout in HTML/CSS (cross-browser compatible back to IE9):
Basically, it's a diagonal line spanning the width of the viewport that divides two background patterns. It will have a fixed height, but it should stretch dynamically to the full width of its container.
I couldn't think of a way to achieve this using purely CSS, so my next thought was to use SVG. This isn't very difficult to do with solid colors:
http://codepen.io/troywarr/pen/EPXVRV?editors=110
But, I'm stumped on how to apply a repeating background pattern to the SVG shape. It will need to line up with the background pattern in the <section>
s above and below, and the background fill shouldn't scale with the dimensions of the shape, or it will appear distorted.
Applying some background images in CSS, I'm getting closer:
http://codepen.io/troywarr/pen/OMgyoE?editors=110
I just need the dark background pattern in the filled portion of the SVG.
Using a more visible image as a test, I'm able to stretch it to the dimensions of my <polyline>
:
http://codepen.io/troywarr/pen/BjZoEq?editors=110
But, there's that stretching that I don't want. I need to tile my pattern, or at least not distort its native dimensions (so I can use a large swatch of it, if needed), even if the shape itself has a fluid width. I've tried several different combinations of attribute values for the <pattern>
element, but I've yet to find anything that works as intended, even following some guidance from related answers:
- Fill SVG path element with a background-image
- Add a background image (.png) to a SVG circle shape
- Fill SVG path element with a background image without tiling or scaling
Any suggestions? I'd love to hear any ideas for non-SVG approaches as well. Thanks!
UPDATE:
Sorry, I just realized that the background patterns in my CodePen examples weren't working. I've updated them with working image URLs.