If I understood well, in your case I would put both svg-bars on my own. Maybe grouped in a div.
(In the next snippet, you still need to add some media queries to put ul in the middle of the black bar and the entire .navigation element. But I think you will understand this idea)
.hero { position: relative; } .hero-bg { height:20vh; min-height:200px; max-height:350px; width:100%; background:url('http://placehold.it/1920x1080'); background-size:cover; z-index: -1; position: absolute; } .navigation { position:relative; width: 100vw; min-height: auto; height: auto; overflow:hidden; padding-top: 185px; } .svg-wrapper { position: absolute; width: 100%; height: 100%; } .nav-bg-1 { width: 105vw; position: absolute; z-index: -1; height: 50px; height: auto; left:-1em; } .nav-bg-rect-1 { fill: red } .nav-bg-rect-2 { fill: black; } .navigation ul { list-style-type:none; padding:0; margin:0; position:relative; padding: .6rem 1rem 1rem; height: 100%; width: 100%; transform: rotate(-1.01deg); } .navigation ul > li { display:inline-block; } .navigation ul > li > a{ color:white; display: block; //padding: 2rem 1rem; text-transform:uppercase; text-decoration:none; }
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-beta.2/css/bootstrap.css" rel="stylesheet"/> <section id="hero" class="hero"> <div class="hero-bg"></div> <div class="navigation"> <div class="svg-wrapper"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1117.79 73" class="nav-bg-1"> <defs></defs><title>rectred</title><g id="Laag_2" data-name="Laag 2"><g id="Laag_1-2" data-name="Laag 1"><rect class="nav-bg-rect-1" x="534.9" y="-522" width="48" height="1117" transform="matrix(0.02, -1, 1, 0.02, 509.89, 594.44)"/></g></g> </svg> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1117.8 79.83" class="nav-bg-1"> <title>rectblack</title><g id="Laag_2" data-name="Laag 2"><g id="Laag_1-2" data-name="Laag 1"><rect class="nav-bg-rect-2" x="0.4" y="7.92" width="1117" height="64" transform="translate(-0.51 7.93) rotate(-0.81)"/></g></g> </svg> </div> <div class="container"> <div class="row"> <div class="col-sm-4 hidden-xs"> </div> <div class="col-sm-8"> <ul class="nav-bar"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Products</a></li> <li><a href="#">Contact</a></li> </ul> </div> </div> </div> </div> </section>
I think it is easy to read / work with two separate svg elements. In this case, wrapped in a div. Built behind the navigation list.
If I see correctly, your menu rotates slightly (like a black bar?). So, I suppose you do not change this bar. Otherwise, I do not see what will happen to your menu.
If this is not what you are looking for, could you explain in more detail what transformation you will add to this bar?
Just in case, codepen, where I worked on it: https://codepen.io/fspin/pen/YYJyNY . (There is a funny scroll in the fragment!)
Update . I thought further. It could also be something in the right direction: https://codepen.io/fspin/pen/zpmdOd
There are a few things you will have to consider, I think:
- For the svg stream to exit the viewport, you would use
vw and vh as units, and your container would have the overflow hidden property. - To track the position of your black bar, you may need to put it directly into the container. This will cause another problem: it will not exit the viewport. So maybe with two svg? One inside the container and one (real) in the svg shell?
Maybe I overdid it, but I like the challenge. I would like to know more about whether I am thinking in the right direction.
Disclaimer: I am not an expert in SVG, nor in CSS, but I think I understand enough to try to solve this in a not-too-hacked way.
source share