I've been hacking my way around this issue for a few websites now. It's time to ask in the open.
I have a navigation bar with a few elements. One of them, the logo, needs to stay centered.
I use flexbox. Is it possible to achieve this using flex rules, without resorting to absolute positioning? This never works for me in small screens, as elements will start mounting on top of each other.
Here is a Codepen with the exact problem, followed by my header markup.
<header role="banner">
<button>Button</button>
<h1>
<a href="/">
<img class="logo" src="http://pre04.deviantart.net/239a/th/pre/i/2014/106/6/c/random_logo_by_criticl-d7eqdvw.png" alt="Logo">
</a>
</h1>
<nav role="navigation">
<ul class="primaryNav">
<li>link 1</li>
<li>link 2</li>
</ul>
<ul class="secondaryNav">
<li><svg viewBox="0 0 512 512"><path d="M211.9 197.4h-36.7v59.9h36.7V433.1h70.5V256.5h49.2l5.2-59.1h-54.4c0 0 0-22.1 0-33.7 0-13.9 2.8-19.5 16.3-19.5 10.9 0 38.2 0 38.2 0V82.9c0 0-40.2 0-48.8 0 -52.5 0-76.1 23.1-76.1 67.3C211.9 188.8 211.9 197.4 211.9 197.4z"/></svg></li>
<li><svg viewBox="0 0 512 512"><path d="M179.7 237.6L179.7 284.2 256.7 284.2C253.6 304.2 233.4 342.9 179.7 342.9 133.4 342.9 95.6 304.4 95.6 257 95.6 209.6 133.4 171.1 179.7 171.1 206.1 171.1 223.7 182.4 233.8 192.1L270.6 156.6C247 134.4 216.4 121 179.7 121 104.7 121 44 181.8 44 257 44 332.2 104.7 393 179.7 393 258 393 310 337.8 310 260.1 310 251.2 309 244.4 307.9 237.6L179.7 237.6 179.7 237.6ZM468 236.7L429.3 236.7 429.3 198 390.7 198 390.7 236.7 352 236.7 352 275.3 390.7 275.3 390.7 314 429.3 314 429.3 275.3 468 275.3"/></svg></li>
<li><svg viewBox="0 0 512 512"><path d="M419.6 168.6c-11.7 5.2-24.2 8.7-37.4 10.2 13.4-8.1 23.8-20.8 28.6-36 -12.6 7.5-26.5 12.9-41.3 15.8 -11.9-12.6-28.8-20.6-47.5-20.6 -42 0-72.9 39.2-63.4 79.9 -54.1-2.7-102.1-28.6-134.2-68 -17 29.2-8.8 67.5 20.1 86.9 -10.7-0.3-20.7-3.3-29.5-8.1 -0.7 30.2 20.9 58.4 52.2 64.6 -9.2 2.5-19.2 3.1-29.4 1.1 8.3 25.9 32.3 44.7 60.8 45.2 -27.4 21.4-61.8 31-96.4 27 28.8 18.5 63 29.2 99.8 29.2 120.8 0 189.1-102.1 185-193.6C399.9 193.1 410.9 181.7 419.6 168.6z"/></svg></li>
</ul>
</nav>
</header>
You could wrap the three sections of the banner with a div like this:
<header role="banner">
<div class="banner-block">
...
</div>
<div class="banner-block">
...
</div>
<div class="banner-block">
...
</div>
</header>
The three banner-block flex items can then be evenly spaced across the banner with this CSS:
.banner-block {
width: 33.333% ;
flex: 1 0;
}
And the h1 logo in the middle can be centered using this:
h1 {
margin: 0 auto;
}
See this updated codepen
Related
This question already has answers here:
How to resize the ClipPath area of SVG?
(2 answers)
masking image with CSS
(2 answers)
Closed 10 months ago.
I'm trying to figure out a way to use an SVG path to hide portions of divs via CSS. The current method I know is using the SVG to clip the entire div. I'm wondering if there's a way to use a mask instead.
My desired result would be to clip only a portion of the div. For the example I was working on, would be the right side of the div.
I've linked my attempts, but at best I can only get clipping to work.
JSFiddle link.
.st0{fill:#000;}
div {
height: 100px;
background: red;
margin-bottom: 20px;
}
.wide {
width: 80%;
}
.short {
width: 20%;
}
.mask {
clip-path: url(#clip);
}
<div class="mask wide"></div>
<div class="mask short"></div>
<svg viewBox="0 0 119.5 290.5">
<defs>
<clippath id="clip">
<path class="st0" d="M12.1,0l27.1,35.2L18.8,72.1l49.3,41.3L9.9,172.6c0,0,43.6,47.1,44.4,44.9c0.9-2.2,36,12.9,32,13.3
s-63.6,12-63.6,12s6.2,17.8,7.6,17.8c1.3,0,55.1,0.9,53.8,0c-1.3-0.9-47.6,17.3-47.6,17.3l-21.3,12.6h104.2V0H12.1z"/>
</clippath>
</defs>
</svg>
Browser support for CSS masks is patchy at present.
However, depending on your requirements, you may be able to use CSS blend modes instead – see the example below. I have yet to find detailed, precise, non-technical descriptions of each blend mode – the best I have found today is this. Some experimentation may be required.
body {
margin: 5vh 5vw;
font-family: sans-serif;
background: #ddd;
}
.background {
background-image: url("https://images.unsplash.com/photo-1531786343146-f297424a3171?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80");
background-repeat: no-repeat;
background-size: cover;
background-position: 50% 50%;
height: 90vh;
position: relative;
}
.overlay {
position: absolute;
top: 5vh;
left: 5vw;
right: 5vw;
bottom: 5vh;
background-color: transparent;
transition: all 600ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.overlay-text {
font-size: 20pt;
color: white;
display: inline-block;
position: relative;
}
.overlay-shape {
fill: white;
}
.overlay:hover {
background-color: #ffffffee;
mix-blend-mode: lighten; /* the overlay is painted only in areas where it is lighter than its parent (the background) */
}
.overlay:hover .overlay-text {
color: black;
}
.overlay:hover .overlay-shape {
fill: black;
}
<section class="background">
<div class="overlay">
<h1 class="overlay-text">HOVER ME.</h1>
<svg viewBox="0 0 1642 1920" xmlns="http://www.w3.org/2000/svg">
<path class="overlay-shape" d="m8071 19178c-20-52-31-109-71-340-22-130-52-270-66-310-64-181-200-376-489-703-316-357-419-485-518-646-188-304-308-621-386-1014-69-348-73-782-11-1170 38-236 61-508 70-825 11-347 17-416 55-624 95-518 236-1077 390-1556 35-107 86-256 113-330 48-127 64-180 143-455 43-152 144-464 180-560 47-122 66-166 155-355 84-180 137-316 192-500 50-164 90-320 82-315-5 3-20 26-36 53-57 99-261 420-393 619-275 416-294 456-530 1118-16 44-79 224-141 400-100 287-224 625-300 820-15 39-39 99-53 135-103 265-311 724-439 969-295 565-575 943-883 1190-342 275-680 465-1095 614-158 57-278 92-571 166-481 121-711 237-930 471-62 66-114 118-116 116-2-1 30-120 71-262 116-403 173-647 212-906 34-231 29-755-12-1193-75-792 266-1701 914-2435 137-156 455-470 625-617 292-255 570-443 892-607 61-30 108-55 105-56-3 0-30 9-60 19-550 191-677 239-895 336-418 186-696 250-1085 249-293 0-459-28-761-128-74-24-188-58-254-76-252-66-318-90-665-238-289-122-420-176-514-208-99-34-359-88-695-144-162-28-296-52-298-54-8-8 104-44 202-65 154-33 221-84 580-445 272-274 440-436 550-530 167-142 583-395 960-582 377-186 570-254 920-324 88-17 237-49 330-71 168-38 174-39 520-54 525-23 1114-37 1255-30 69 4 168 16 220 26 52 11 127 27 165 35 209 43 587 152 790 229 228 86 282 111 725 338 135 69 310 154 390 190 146 65 340 141 345 135 4-3-81-75-210-177-84-66-297-210-377-253-79-44-267-129-362-164-97-37-356-114-380-114-14 0-212-66-331-110-111-41-359-167-498-253-76-47-242-160-370-250-268-189-323-225-582-372-347-196-532-331-710-516-130-135-210-243-342-464-337-566-707-1019-1100-1348-137-115-173-150-173-173 0-14 139 6 277 40 148 37 500 135 758 211 370 110 488 142 730 196 440 98 527 119 730 170 677 171 991 284 1252 454 97 63 157 113 343 285 69 64 179 162 245 220 159 138 438 418 502 504 108 146 152 240 301 641 87 235 258 795 343 1122 12 46 23 83 26 83 2 0 3-593 2-1317-3-1656 6-2409 36-3133 58-1347 59-1395 60-2195 0-831 0-839-51-1090-44-215-64-358-64-453 0-120 14-153 84-193 54-31 97-36 143-18 15 6 51 11 80 10 65-2 107 18 122 59 8 23 5 125-9 393-38 710-50 1019-60 1527-19 989-32 1309-85 2112-41 606-50 953-65 2398-6 553-15 1156-20 1340s-9 358-9 385v50l24-85c117-421 505-1058 909-1490 291-311 669-585 1091-790 180-87 358-155 705-268 431-140 614-217 805-338 200-126 328-165 886-268 135-26 293-59 350-75 301-85 594-219 990-452 64-38 119-69 123-69 36 0-126 285-407 714-106 161-193 311-294 505-194 370-240 452-349 616-185 281-327 428-562 581-81 53-243 169-360 258-278 210-469 347-595 426-214 135-476 255-689 316-54 15-96 29-94 31s48-7 102-21c170-42 351-51 1019-51 673 0 689 1 1039 65 577 105 757 158 1147 336 267 121 696 354 877 476 154 104 304 234 672 587 262 251 326 308 433 385 83 59 101 66 236 91 46 9 102 23 124 32 51 21 43 24-118 53-166 29-526 104-666 139-141 35-228 69-569 223-456 206-488 219-756 298-72 21-164 50-205 65-270 98-482 147-714 166-372 30-761-42-1180-218-71-30-179-73-240-95-60-22-145-52-187-68-43-15-78-26-78-24 0 1 48 36 108 76 265 180 538 430 723 663 53 66 149 197 214 290 136 196 235 329 350 470 204 251 326 431 410 610 102 217 166 463 185 718 21 279 39 385 89 540 94 293 141 532 151 772 5 105 17 261 29 347 17 136 26 174 72 295 69 185 154 377 246 553 80 154 141 250 254 395 64 83 117 171 107 180-2 2-62-30-133-72-328-191-679-380-800-432-98-41-259-89-630-186-465-122-519-140-845-283-74-32-153-65-175-72-284-91-559-238-790-420-123-97-350-332-449-465-136-185-215-317-362-610-132-262-222-432-289-545-18-30-89-149-157-265-307-516-444-777-548-1040-66-165-149-340-230-480-35-60-81-141-103-180-137-238-223-478-307-860-103-469-163-659-253-809-39-65-201-267-261-326-39-37-49-43-64-33-9 6-16 15-15 20 2 9 509 1275 568 1418 21 50 48 116 61 148 13 31 35 83 48 115 13 31 40 95 61 142 181 416 268 691 385 1220 72 324 109 456 235 835 163 490 232 823 266 1270 14 190 21 1674 8 1845-33 462-221 862-615 1311-56 64-239 253-405 420-527 529-566 593-668 1093-21 102-41 189-44 192-4 4-11-5-16-18zm-2212-9354c134-49 153-57 546-215 193-77 370-149 395-159 25-9 86-34 135-55 552-228 885-353 984-370 38-6 41-9 41-40 0-38-12-45-74-45-55 0-241 34-389 71-211 53-359 122-527 247-225 167-332 221-685 350-60 22-146 56-190 75-85 36-356 177-341 177 4 0 52-16 105-36zm3576-403c-29-27-323-243-400-294-215-141-397-197-646-197h-116l-7 32c-11 56 34 98 189 175 211 106 493 194 865 271 112 23 127 25 115 13zm-948-666c274-56 532-161 923-375 139-76 273-139 439-207 152-61 477-171 589-198 40-9 71-20 68-22-3-3-78 11-168 31s-257 56-373 81c-262 57-467 114-604 167-58 23-270 123-471 223-414 206-468 230-571 247-85 13-101 23-88 56 7 19 15 22 70 22 34 0 118-11 186-25z" transform="matrix(.1 0 0 -.1 0 1920)"/>
</svg>
</div>
</section>
Credits: code image
I have an SVG that I need to be on the opposite side of the card and reversed. Any changes I seem to make only move it up a little or make it disappear. Any help would be much appreciated:
This Picture below is what I have, but the svg needs to be on the other side and turned about as to finish the paragraph.
<div class="row featurette" id="ourMission">
<div class="col-md-7">
<div class="card">
<div class="card-body">
<span class="svg-icon text-primary mb-3">
<svg width="300" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.5001 5.84998C9.0001 7.64998 5.4001 12.15 5.4001 16.2C5.4001 17.1 5.4001 18 5.8501 18.45C6.7501 17.55 8.1001 17.1 9.9001 17.1C13.5001 17.1 16.6501 19.8 16.6501 23.85C16.6501 27.9 13.5001 30.6 9.9001 30.6C6.3001 31.05 4.5001 29.7 3.1501 27.45C1.8001 25.2 1.3501 22.05 1.3501 20.25C1.3501 13.05 4.9501 7.19998 12.6001 3.59998L13.5001 5.84998ZM31.9501 5.84998C27.4501 7.64998 23.8501 12.15 23.8501 16.2C23.8501 17.1 23.8501 18 24.3001 18.45C25.2001 17.55 26.5501 17.1 28.3501 17.1C31.9501 17.1 35.1001 19.8 35.1001 23.85C35.1001 27.9 31.9501 30.6 28.3501 30.6C25.2001 30.6 23.4001 29.25 22.0501 27C19.8001 25.2 19.8001 22.05 19.8001 20.25C19.8001 13.05 23.4001 7.19998 31.0501 3.59998L31.9501 5.84998Z" fill="#377dff"/>
</svg>
</span>
<!-- Blockquote -->
<figure>
<blockquote class="blockquote blockquote-sm">
<!--IN The size-->
Why not just put the svg another time after the content and apply a rotate ?
<div class="row featurette" id="ourMission">
<div class="col-md-7">
<div class="card">
<div class="card-body">
<span class="svg-icon text-primary mb-3">
<svg width="300" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.5001 5.84998C9.0001 7.64998 5.4001 12.15 5.4001 16.2C5.4001 17.1 5.4001 18 5.8501 18.45C6.7501 17.55 8.1001 17.1 9.9001 17.1C13.5001 17.1 16.6501 19.8 16.6501 23.85C16.6501 27.9 13.5001 30.6 9.9001 30.6C6.3001 31.05 4.5001 29.7 3.1501 27.45C1.8001 25.2 1.3501 22.05 1.3501 20.25C1.3501 13.05 4.9501 7.19998 12.6001 3.59998L13.5001 5.84998ZM31.9501 5.84998C27.4501 7.64998 23.8501 12.15 23.8501 16.2C23.8501 17.1 23.8501 18 24.3001 18.45C25.2001 17.55 26.5501 17.1 28.3501 17.1C31.9501 17.1 35.1001 19.8 35.1001 23.85C35.1001 27.9 31.9501 30.6 28.3501 30.6C25.2001 30.6 23.4001 29.25 22.0501 27C19.8001 25.2 19.8001 22.05 19.8001 20.25C19.8001 13.05 23.4001 7.19998 31.0501 3.59998L31.9501 5.84998Z" fill="#377dff"/>
</svg>
</span>
<!-- Blockquote -->
<figure>
<blockquote class="blockquote blockquote-sm">
<!--IN The size-->
<svg width="300" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg" style="transform:rotate(180deg)">
<path d="M13.5001 5.84998C9.0001 7.64998 5.4001 12.15 5.4001 16.2C5.4001 17.1 5.4001 18 5.8501 18.45C6.7501 17.55 8.1001 17.1 9.9001 17.1C13.5001 17.1 16.6501 19.8 16.6501 23.85C16.6501 27.9 13.5001 30.6 9.9001 30.6C6.3001 31.05 4.5001 29.7 3.1501 27.45C1.8001 25.2 1.3501 22.05 1.3501 20.25C1.3501 13.05 4.9501 7.19998 12.6001 3.59998L13.5001 5.84998ZM31.9501 5.84998C27.4501 7.64998 23.8501 12.15 23.8501 16.2C23.8501 17.1 23.8501 18 24.3001 18.45C25.2001 17.55 26.5501 17.1 28.3501 17.1C31.9501 17.1 35.1001 19.8 35.1001 23.85C35.1001 27.9 31.9501 30.6 28.3501 30.6C25.2001 30.6 23.4001 29.25 22.0501 27C19.8001 25.2 19.8001 22.05 19.8001 20.25C19.8001 13.05 23.4001 7.19998 31.0501 3.59998L31.9501 5.84998Z" fill="#377dff"/>
</svg>
I have a fixed footer on the following website;
https://sen-seis.com/dev/
I would like to be able to change the contents of the footer if the website is accessed from a mobile phone.
Is there a way to amend the footer.php file to only display certain parts of the footer if using the mobile. The code is;
<footer id="colophon" class="site-footer" role="contentinfo" <?php sydney_do_schema( 'footer' ); ?>>
<table width="80%" border="0px" align="center">
<tr border="0px">
<td width="25%"><div class="site-info">
Copyright <?php echo date('Y'); ?> © Sen Seis. All rights reserved
</div><!-- .site-info -->
<!-- .site-info --> </td>
<td width="20%"> <div class="contact-email" ><span><i class="sydney-svg-icon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#069146" d="M502.3 190.8c3.9-3.1 9.7-.2 9.7 4.7V400c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V195.6c0-5 5.7-7.8 9.7-4.7 22.4 17.4 52.1 39.5 154.1 113.6 21.1 15.4 56.7 47.8 92.2 47.6 35.7.3 72-32.8 92.3-47.6 102-74.1 131.6-96.3 154-113.7zM256 320c23.2.4 56.6-29.2 73.4-41.4 132.7-96.3 142.8-104.7 173.4-128.7 5.8-4.5 9.2-11.5 9.2-18.9v-19c0-26.5-21.5-48-48-48H48C21.5 64 0 85.5 0 112v19c0 7.4 3.4 14.3 9.2 18.9 30.6 23.9 40.7 32.4 173.4 128.7 16.8 12.2 50.2 41.8 73.4 41.4z"></path> </svg></i></span> <b> info#sen-seis.com</b> </div>
</td>
<td>
<a href="https://www.facebook.com/relaxmymuscles/" > <svg xmlns="http://www.w3.org/2000/svg" width="27" height="27" viewBox="0 0 24 24" fill="#069146"><path d="M12 0c6.627 0 12 5.373 12 12s-5.373 12-12 12S0 18.627 0 12 5.373 0 12 0zm4 7.278V4.5h-2.286c-2.1 0-3.428 1.6-3.428 3.889v1.667H8v2.777h2.286V19.5h2.857v-6.667h2.286L16 10.056h-2.857V8.944c0-1.11.572-1.666 1.714-1.666H16z"/></svg> </a href>
<a href="https://www.instagram.com/senseis._/" > <svg xmlns="http://www.w3.org/2000/svg" width="27" height="27" viewBox="0 0 24 24" fill="#069146"><path d="M12 0c6.6274 0 12 5.3726 12 12s-5.3726 12-12 12S0 18.6274 0 12 5.3726 0 12 0zm3.115 4.5h-6.23c-2.5536 0-4.281 1.6524-4.3805 4.1552L4.5 8.8851v6.1996c0 1.3004.4234 2.4193 1.2702 3.2359.7582.73 1.751 1.1212 2.8818 1.1734l.2633.006h6.1694c1.3004 0 2.389-.4234 3.1754-1.1794.762-.734 1.1817-1.7576 1.2343-2.948l.0056-.2577V8.8851c0-1.2702-.4234-2.3589-1.2097-3.1452-.7338-.762-1.7575-1.1817-2.9234-1.2343l-.252-.0056zM8.9152 5.8911h6.2299c.9072 0 1.6633.2722 2.2076.8166.4713.499.7647 1.1758.8103 1.9607l.0063.2167v6.2298c0 .9375-.3327 1.6936-.877 2.2077-.499.4713-1.176.7392-1.984.7806l-.2237.0057H8.9153c-.9072 0-1.6633-.2722-2.2076-.7863-.499-.499-.7693-1.1759-.8109-2.0073l-.0057-.2306V8.885c0-.9073.2722-1.6633.8166-2.2077.4712-.4713 1.1712-.7392 1.9834-.7806l.2242-.0057h6.2299-6.2299zM12 8.0988c-2.117 0-3.871 1.7238-3.871 3.871A3.8591 3.8591 0 0 0 12 15.8408c2.1472 0 3.871-1.7541 3.871-3.871 0-2.117-1.754-3.871-3.871-3.871zm0 1.3911c1.3609 0 2.4798 1.119 2.4798 2.4799 0 1.3608-1.119 2.4798-2.4798 2.4798-1.3609 0-2.4798-1.119-2.4798-2.4798 0-1.361 1.119-2.4799 2.4798-2.4799zm4.0222-2.3589a.877.877 0 1 0 0 1.754.877.877 0 0 0 0-1.754z"/></svg> </a href>
<a href="https://www.google.com/maps/place/Sen-Seis+Massage+Therapy/#51.5969996,-0.284717,15z/data=!4m5!3m4!1s0x0:0x62567b567dd73a63!8m2!3d51.5970056!4d-0.2847197">
<svg xmlns="http://www.w3.org/2000/svg" width="27" height="27" viewBox="0 0 24 24" fill="none" stroke="#069146" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="10" r="3"/><path d="M12 21.7C17.3 17 20 13 20 10a8 8 0 1 0-16 0c0 3 2.7 6.9 8 11.7z"/></svg>
</a>
<a href="https://wa.me/447368647489">
<svg xmlns="http://www.w3.org/2000/svg" width="27" height="27" viewBox="0 0 24 24" fill="#069146"><path d="M12 0a12 12 0 1 1 0 24 12 12 0 0 1 0-24zm.14 4.5a7.34 7.34 0 0 0-6.46 10.82l.15.26L4.5 19.5l4.08-1.3a7.38 7.38 0 0 0 10.92-6.4c0-4.03-3.3-7.3-7.36-7.3zm0 1.16c3.41 0 6.19 2.76 6.19 6.15a6.17 6.17 0 0 1-9.37 5.27l-.23-.15-2.38.76.77-2.28a6.08 6.08 0 0 1-1.17-3.6 6.17 6.17 0 0 1 6.19-6.15zM9.66 8.47a.67.67 0 0 0-.48.23l-.14.15c-.2.23-.5.65-.5 1.34 0 .72.43 1.41.64 1.71l.14.2a7.26 7.26 0 0 0 3.04 2.65l.4.14c1.44.54 1.47.33 1.77.3.33-.03 1.07-.43 1.22-.85.15-.42.15-.78.1-.85-.02-.05-.08-.08-.15-.12l-1.12-.54a5.15 5.15 0 0 0-.3-.13c-.17-.06-.3-.1-.41.09-.12.18-.47.58-.57.7-.1.1-.18.13-.32.08l-.4-.18a4.64 4.64 0 0 1-2.13-1.98c-.1-.18-.01-.28.08-.37l.27-.31c.1-.1.12-.18.18-.3a.3.3 0 0 0 .01-.26l-.1-.23-.48-1.15c-.15-.36-.3-.3-.4-.3l-.35-.02z"/></svg>
</a>
</td>
</tr>
</table>
</footer><!-- #colophon -->
Yo
Tty this
#media screen and (max-width:1200) {
.texttohide {
display : none;
}
}
<div>
<span class="textodisplayallthetime">BLABLABLA</span>
<span class="texttohide">this text will be hidden if the width of the device is under 1200 px, this should work for the majority of the cellphone</span>
</div>
This question already has answers here:
Align 3 unequal blocks left, center and right
(4 answers)
Closed 2 years ago.
I would like to center an element which depends on the viewport. I have a header with five elements inside :
One button on the left
One logo on the middle
Three buttons on the right
I want logo to be center depending of the viewport. I made a codepen :
https://codepen.io/pier6dev/pen/WNvjJGX
The logo is not centered even if i use a justify content center.
The logo should be there :
I'm not sure that i'm very clear, ask any questions if you have.
header {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 1rem;
}
.btn {
padding: 1rem;
border-radius: 0.5rem;
color: white;
}
.btn.btn-home {
background: red;
}
svg {
width: 10rem;
height: auto;
}
.right {
display: flex;
}
.btn.btn-shop {
background: blue;
margin-right: 1rem;
}
.btn.btn-subscribe {
background: orange;
margin-right: 1rem;
}
.btn.btn-login {
background: grey;
}
<header>
<div class="left">
<div class="btn btn-home">Home</div>
</div>
<div class="center">
<div class="logo">
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 5573.1 1990.2" width="5573.1" height="1990.2">
<style>
.st0 {
fill: #ed1c40
}
</style>
<path class="st0"
d="M3283.8 1072.6c-7.7 11.6-12.6 19.5-17.9 27.2-49.8 71.4-105.8 136.6-182 181.7-102.2 60.4-213 85.3-328.4 60.3-59.2-12.9-114.4-46-170.2-72.5-12.9-6.1-19.9-6.2-31.3.5-47.9 28.2-94.4 59.9-145.1 81.8-89.9 38.9-184.6 60.8-282.5 34.9-61.4-16.2-114.4-50.8-162.4-92.4-34-29.5-36.2-29.5-70.7-1.1-62 51-133.6 83.9-208.5 111.1-92.9 33.7-188.8 54.4-286.8 64.1-119.6 11.8-230.5-8.5-311.4-106.8-64.9-78.8-82.2-170.2-42.5-265.1 43.5-104 93.7-205.2 140.9-307.7 24.6-53.4 49.4-106.7 73.3-160.4 4.4-9.9 6.1-21.4 6.6-32.3.9-20 5-41.9-18.1-54-23.6-12.3-51.5-10.1-68.9 11.9-21.7 27.4-41 57.5-57.1 88.6-53.6 102.8-105.4 206.6-157.7 310.1-39.2 77.6-77.7 155.6-117.2 233-37.5 73.4-107.9 101.4-184.3 72.8-25.7-9.7-41.8-28.6-46.2-57.5-6.1-40.9 7.3-77.6 21.8-114.2 31.7-80.2 63.8-160.2 95.5-240.4 17-43 34-86 49.9-129.4 11.2-30.3 14.5-62.5 1.5-92.3-10.1-23-29.9-39.6-57.7-37.1-30.4 2.7-54.3 18.6-65.8 46.8-40.3 99.5-79 199.7-118.6 299.5-47.4 119.4-94.1 239.2-143.5 357.8-18.3 43.8-45.9 83.8-92.3 102.5-23.5 9.5-50.1 15.4-75.4 15.8-79 1-147.1-25.3-193.7-92.4C0 1264.3-9 1205 8.9 1142.2c16.6-58.1 33.1-116.2 50.5-174 16.5-54.8 33.9-109.4 51-164 15.9-50.9 30.8-102.2 48.1-152.6 34-99.3 61.4-201.5 115.2-292.6 36.8-62.3 96.5-96 164.9-116.9 71.5-21.8 132.5 5.6 193.5 36 23.2 11.5 46 23.8 69.8 33.8 33.2 13.9 63.4 5.1 90.2-16.7 21.9-17.8 44-35.7 64.2-55.4 50.5-49.3 159.5-58.4 212.8-1.1 12.3 13.2 26.8 24.3 40.3 36.3 27.9 24.6 39.4 27.2 71.7 8.9 76.8-43.3 156.3-37.3 234.4-9.6 45.3 16.1 72.5 54.7 89.8 100.3 25.5 67.2 14.8 132-10.7 195.2-47 116.2-98.2 230.6-144 347.2-27.2 69.2-50.1 140.3-69.7 212-8 29.2-8 63.9-.6 93.2 11.2 44.4 51.9 59 93.1 64.2 62.7 7.9 124.2-3.7 184.2-20.3 51.3-14.1 101.8-31.6 151.9-49.7 24.2-8.7 46.7-22.1 69.8-33.9 19.7-10 21.3-24.6 10.9-43-21.2-37.5-43.6-74.5-62.3-113.3-39.6-82-72.1-166.6-63.4-260 7.6-81.8 37.1-152.9 112.6-195.9 111.4-63.5 201.9-46 283.8 48.9 70.8 82.1 94.2 180.9 63.8 286.8-17 59.2-41.4 116.4-64.6 173.7-6.4 15.9-2.7 26 7.3 35.3 46.9 43.8 100.4 77.9 159.8 102 22.4 9.1 46.1 15.9 69.8 20.7 51 10.2 98.4-1.9 140.9-30.8 20.2-13.7 20.7-26.5 6.6-45.7-97.8-133.4-136.5-281.9-107.1-445 11-61.1 39.3-118.8 104.8-136.4 40.5-10.9 86.3-10.4 128.5-5.1 68.5 8.7 130.5 36 172.6 95 50.5 70.8 63.4 148.2 41.6 232.8-15.6 60.8-47.5 112.4-82.6 162.6-13.9 19.9-14.4 38.2 4.5 51.6 29.2 20.5 58.8 43 91.8 54.9 71.6 25.8 146 23.5 218.1.3 79-25.4 134.5-77.8 166.1-155.5 37.8-93 38.3-190.3 36.3-288-1.5-76.3-4.2-152.7-6.5-229.1-.8-27.3-5.2-28.9-31.2-23.6-68.5 13.8-137.3 26.1-206.1 38.7-21.7 3.9-43.5 6.6-65.2 10.5-47.2 8.5-86.2-10.9-88.8-66.1-2.7-55.7-10.8-111.1-16.5-166.6-.3-3.1-.6-6.3-.8-9.4-3.2-65.4 12.6-100.9 91.1-98.1 81 3 162.1 5.6 243 9.9 39.8 2.1 53.8-8 56.4-47.5 2-30.7 2.9-61.4 4.8-92 2.9-46 13.4-56.9 60.1-55.1 27.9 1.1 56 6 83.3 12.1 38.5 8.6 58.6 35.7 61.3 74 2.2 31.3 1.3 62.9.8 94.4-.4 22.3 6.5 34.2 31.4 36.7 72 7.3 143.7 17.3 215.6 25.9 33.9 4 53 17.8 57.6 43 8 43.8-1.5 73.8-34.6 85.8-46.3 16.7-94.1 29.5-141.9 41.3-33.5 8.3-68.1 11.8-102.1 18.1-22.8 4.2-35.2 16.2-35 41.8.9 126.8-2 253.7 1.7 380.4 1.9 66.5 11.9 133 40.2 195.1 22.9 50.3 61.9 70.1 116.3 61 79.7-13.4 152.8-41.4 216.4-91.8 35.3-28 58.6-62.2 60.3-109.5 3.2-86.6 7.5-173.1 12.5-259.5 1.5-24.9 4.3-50.8 12.6-74 4.6-12.9 21.6-30 33.4-30.3 65.1-2 130.7-2.6 195.5 3 40.8 3.5 68.8 41.7 66.6 84.8-2.9 60.4-10.7 120.6-16.5 180.9-7.1 74.4-13.7 148.9-21.6 223.2-8 75.2 52.1 112.5 111.7 113.2 49.9.6 79.4-18 100.6-70.9 22-54.7 35-114 44.5-172.5 13.4-83 19.7-167.2 29.6-250.8 4-34.1 25.3-60.4 51.8-66.1 30.6-6.6 70.9 5.9 80.9 33.9 8.4 23.4 6.5 52 3.6 77.7-10.8 95.2-26.4 190-35.4 285.4-5.5 58.6 27.4 100.3 84.3 117.6 28.4 8.6 57.8 15.4 87.2 18.8 51.6 5.9 88.1-31.8 98.9-90.4 9.1-49.3 10.3-100.1 14.8-150.3 5.2-59.6 5.9-119.9 16.1-178.6 15-86.9 71.1-165.7 175.1-191 62.4-15.2 125.4-17 187.7-9.8 95 10.9 194.5 75.5 224.9 184.7 23.1 83 13.9 163.2-13.2 243-31.5 92.5-88.9 164.6-169.2 219.5-7.4 5.1-11.7 14.7-17.4 22.2 10.1 4.5 20.3 12.9 30.3 12.7 96-1.5 186.4-23.4 269.3-73.7 18.7-11.3 39.1-19.9 58.8-29.3 18.1-8.6 28.8 1.6 23.8 17.2-8.4 26.2-18.5 53.9-35.3 75.1-71 89.8-167.9 132.8-279.9 140.3-47.5 3.2-95.7-3.2-143.6-5.8-36.1-2-72.2-5.2-108.3-7.6-18.3-1.2-28.9 6.5-33.5 25.5-28.8 118.7-44 239.5-58.9 360.5-9.4 76.2-23.6 152.2-41.9 226.8-9.9 40.5-41.5 68.4-85.2 75.4-26.1 4.2-45.5-7.1-54.3-31.5-7.4-20.6-14.3-42.1-16.1-63.7-8.6-106.3-5.1-212.3 9-318.1 7.2-53.8 11.9-107.9 18.1-161.9 4.3-37.5 10-74.9 13.5-112.5 2.8-30.4-4.1-37.5-33.2-43.3-60.1-12-120.3-23.8-180.2-37-40.7-9-72.4 5.4-99.9 33.4-36.6 37.3-77.1 69.6-125.1 90.6-58 25.3-119.5 20-179.1 10.5-86.1-13.7-154.8-59-203.7-131.6-15.2-22.5-26.2-47.9-38.1-72.5-6.7-13.8-12.6-19.1-28.8-10.9-57.2 29.1-114.2 59-173.2 84-65.8 27.8-135.6 37.6-205.5 18.1-68.1-19-120.4-62.9-163.8-117.7-11.7-14.5-23.1-29.3-41.1-52.4zm1962.4-272.7c-.8-9.4-.8-18.9-2.3-28.2-8.7-53.7-62.6-77.7-106.1-45.4-19.6 14.6-37.5 33.9-50.9 54.4-44.8 68.6-65 147.2-85.2 225.4-5.1 19.6-8.6 40.4-8.2 60.5.8 37.5 22.8 48.6 54.3 28.3 65.3-42.1 113.6-100.5 154.4-165.4 24.8-39.3 45.1-80.9 44-129.6zm-2560.8 37.9c.6-37.3-8.1-71.8-35.6-98.7-15.2-14.9-34.3-21.3-56.1-14.5-26.5 8.2-40.8 27.9-42.8 60.5-3.9 63.2 23.3 117.5 51.2 171 14.4 27.5 28.1 26.7 46.6 1.2 26-35.6 36.1-76 36.7-119.5zm-644.3-12.1c-6.9-22.9-11.5-46.8-21.3-68.3-12.6-27.4-45.1-39.7-73.8-32.2-30.4 8-42.4 22.5-39.3 59.9 2.8 32.6 10.3 65.1 18.9 96.7 6.4 23.3 16.2 46.1 27.7 67.3 15.6 28.5 31.9 28.8 47.2 1.2 21.2-38.1 37.6-78 40.6-124.6z" />
</svg>
</div>
</div>
<div class="right">
<div class="btn btn-shop">Shop</div>
<div class="btn btn-subscribe">Subscribe</div>
<div class="btn btn-login">Login</div>
</div>
</header>
I have fixed it by converting the .center into an absolute element. You can specify a fixed width to the logo.
.center {
position: absolute;
left: 0;
right: 0;
margin: auto;
width: 160px;
}
Link to the codepen
The problem you will face is that your button elements on the right will take up too much space. So when scaling down to smaller screens the <div class="right"> group need space to show on the screen.
One solution, which I don't overly recommend as you'll have overflow issues is below:
.left, .right {
width: 20%; // or 25% (means they will take 50% of the width combined)
}
.center {
width: 50%; // take up remaining 50%
display: flex;
align-items: center;
justify-content: center;
// flex will now position .logo container center
}
Another approach which for me is something I would do is to determine which elements/buttons are needed in smaller screens and think of using a Sidedrawer/Pullout menu. A link to W3Schools is below to help with that.
https://www.w3schools.com/howto/howto_js_sidenav.asp
Also then you can use Media queries to set when a 'Full' Header menu is to be available for suitable screen widths.
Two common media queries are:
// Tablet Media Query for screens at a minimum width of 768px
#media screen and (min-width: 768px) {}
// Desktop Media Query for screens at a minimum width of 1024px
#media screen and (min-width: 1024px) {}
Your logo does not depend on the viewport, it depends on the flexbox it's inside of. There is no way to make it ignore its parent container and center to the viewport.
Instead you can make the .right and .left classes (the ones wrapping your home and other buttons) the same width. This will make sure that the space left in the middle is perfectly centered. In this example I've added display: flex and justify-items: start to .left as well to prevent the home button from stretching and set the width to the width of the larger div shown in the inspector. With this solution you'll have to break to a different layout pretty early on with a media query since the logo starts touching the buttons on the right around 768px viewport width which looks odd.
header {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 1rem;
}
.btn {
padding: 1rem;
border-radius: 0.5rem;
color: white;
}
.btn.btn-home {
background: red;
}
svg {
width: 10rem;
height: auto;
}
.left, .right {
width: 272px;
display: flex;
}
.left {
justify-items: start
}
.btn.btn-shop {
background: blue;
margin-right: 1rem;
}
.btn.btn-subscribe {
background: orange;
margin-right: 1rem;
}
.btn.btn-login {
background: grey;
}
<header>
<div class="left">
<div class="btn btn-home">Home</div>
</div>
<div class="center">
<div class="logo">
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 5573.1 1990.2" width="5573.1" height="1990.2">
<style>
.st0 {
fill: #ed1c40
}
</style>
<path class="st0"
d="M3283.8 1072.6c-7.7 11.6-12.6 19.5-17.9 27.2-49.8 71.4-105.8 136.6-182 181.7-102.2 60.4-213 85.3-328.4 60.3-59.2-12.9-114.4-46-170.2-72.5-12.9-6.1-19.9-6.2-31.3.5-47.9 28.2-94.4 59.9-145.1 81.8-89.9 38.9-184.6 60.8-282.5 34.9-61.4-16.2-114.4-50.8-162.4-92.4-34-29.5-36.2-29.5-70.7-1.1-62 51-133.6 83.9-208.5 111.1-92.9 33.7-188.8 54.4-286.8 64.1-119.6 11.8-230.5-8.5-311.4-106.8-64.9-78.8-82.2-170.2-42.5-265.1 43.5-104 93.7-205.2 140.9-307.7 24.6-53.4 49.4-106.7 73.3-160.4 4.4-9.9 6.1-21.4 6.6-32.3.9-20 5-41.9-18.1-54-23.6-12.3-51.5-10.1-68.9 11.9-21.7 27.4-41 57.5-57.1 88.6-53.6 102.8-105.4 206.6-157.7 310.1-39.2 77.6-77.7 155.6-117.2 233-37.5 73.4-107.9 101.4-184.3 72.8-25.7-9.7-41.8-28.6-46.2-57.5-6.1-40.9 7.3-77.6 21.8-114.2 31.7-80.2 63.8-160.2 95.5-240.4 17-43 34-86 49.9-129.4 11.2-30.3 14.5-62.5 1.5-92.3-10.1-23-29.9-39.6-57.7-37.1-30.4 2.7-54.3 18.6-65.8 46.8-40.3 99.5-79 199.7-118.6 299.5-47.4 119.4-94.1 239.2-143.5 357.8-18.3 43.8-45.9 83.8-92.3 102.5-23.5 9.5-50.1 15.4-75.4 15.8-79 1-147.1-25.3-193.7-92.4C0 1264.3-9 1205 8.9 1142.2c16.6-58.1 33.1-116.2 50.5-174 16.5-54.8 33.9-109.4 51-164 15.9-50.9 30.8-102.2 48.1-152.6 34-99.3 61.4-201.5 115.2-292.6 36.8-62.3 96.5-96 164.9-116.9 71.5-21.8 132.5 5.6 193.5 36 23.2 11.5 46 23.8 69.8 33.8 33.2 13.9 63.4 5.1 90.2-16.7 21.9-17.8 44-35.7 64.2-55.4 50.5-49.3 159.5-58.4 212.8-1.1 12.3 13.2 26.8 24.3 40.3 36.3 27.9 24.6 39.4 27.2 71.7 8.9 76.8-43.3 156.3-37.3 234.4-9.6 45.3 16.1 72.5 54.7 89.8 100.3 25.5 67.2 14.8 132-10.7 195.2-47 116.2-98.2 230.6-144 347.2-27.2 69.2-50.1 140.3-69.7 212-8 29.2-8 63.9-.6 93.2 11.2 44.4 51.9 59 93.1 64.2 62.7 7.9 124.2-3.7 184.2-20.3 51.3-14.1 101.8-31.6 151.9-49.7 24.2-8.7 46.7-22.1 69.8-33.9 19.7-10 21.3-24.6 10.9-43-21.2-37.5-43.6-74.5-62.3-113.3-39.6-82-72.1-166.6-63.4-260 7.6-81.8 37.1-152.9 112.6-195.9 111.4-63.5 201.9-46 283.8 48.9 70.8 82.1 94.2 180.9 63.8 286.8-17 59.2-41.4 116.4-64.6 173.7-6.4 15.9-2.7 26 7.3 35.3 46.9 43.8 100.4 77.9 159.8 102 22.4 9.1 46.1 15.9 69.8 20.7 51 10.2 98.4-1.9 140.9-30.8 20.2-13.7 20.7-26.5 6.6-45.7-97.8-133.4-136.5-281.9-107.1-445 11-61.1 39.3-118.8 104.8-136.4 40.5-10.9 86.3-10.4 128.5-5.1 68.5 8.7 130.5 36 172.6 95 50.5 70.8 63.4 148.2 41.6 232.8-15.6 60.8-47.5 112.4-82.6 162.6-13.9 19.9-14.4 38.2 4.5 51.6 29.2 20.5 58.8 43 91.8 54.9 71.6 25.8 146 23.5 218.1.3 79-25.4 134.5-77.8 166.1-155.5 37.8-93 38.3-190.3 36.3-288-1.5-76.3-4.2-152.7-6.5-229.1-.8-27.3-5.2-28.9-31.2-23.6-68.5 13.8-137.3 26.1-206.1 38.7-21.7 3.9-43.5 6.6-65.2 10.5-47.2 8.5-86.2-10.9-88.8-66.1-2.7-55.7-10.8-111.1-16.5-166.6-.3-3.1-.6-6.3-.8-9.4-3.2-65.4 12.6-100.9 91.1-98.1 81 3 162.1 5.6 243 9.9 39.8 2.1 53.8-8 56.4-47.5 2-30.7 2.9-61.4 4.8-92 2.9-46 13.4-56.9 60.1-55.1 27.9 1.1 56 6 83.3 12.1 38.5 8.6 58.6 35.7 61.3 74 2.2 31.3 1.3 62.9.8 94.4-.4 22.3 6.5 34.2 31.4 36.7 72 7.3 143.7 17.3 215.6 25.9 33.9 4 53 17.8 57.6 43 8 43.8-1.5 73.8-34.6 85.8-46.3 16.7-94.1 29.5-141.9 41.3-33.5 8.3-68.1 11.8-102.1 18.1-22.8 4.2-35.2 16.2-35 41.8.9 126.8-2 253.7 1.7 380.4 1.9 66.5 11.9 133 40.2 195.1 22.9 50.3 61.9 70.1 116.3 61 79.7-13.4 152.8-41.4 216.4-91.8 35.3-28 58.6-62.2 60.3-109.5 3.2-86.6 7.5-173.1 12.5-259.5 1.5-24.9 4.3-50.8 12.6-74 4.6-12.9 21.6-30 33.4-30.3 65.1-2 130.7-2.6 195.5 3 40.8 3.5 68.8 41.7 66.6 84.8-2.9 60.4-10.7 120.6-16.5 180.9-7.1 74.4-13.7 148.9-21.6 223.2-8 75.2 52.1 112.5 111.7 113.2 49.9.6 79.4-18 100.6-70.9 22-54.7 35-114 44.5-172.5 13.4-83 19.7-167.2 29.6-250.8 4-34.1 25.3-60.4 51.8-66.1 30.6-6.6 70.9 5.9 80.9 33.9 8.4 23.4 6.5 52 3.6 77.7-10.8 95.2-26.4 190-35.4 285.4-5.5 58.6 27.4 100.3 84.3 117.6 28.4 8.6 57.8 15.4 87.2 18.8 51.6 5.9 88.1-31.8 98.9-90.4 9.1-49.3 10.3-100.1 14.8-150.3 5.2-59.6 5.9-119.9 16.1-178.6 15-86.9 71.1-165.7 175.1-191 62.4-15.2 125.4-17 187.7-9.8 95 10.9 194.5 75.5 224.9 184.7 23.1 83 13.9 163.2-13.2 243-31.5 92.5-88.9 164.6-169.2 219.5-7.4 5.1-11.7 14.7-17.4 22.2 10.1 4.5 20.3 12.9 30.3 12.7 96-1.5 186.4-23.4 269.3-73.7 18.7-11.3 39.1-19.9 58.8-29.3 18.1-8.6 28.8 1.6 23.8 17.2-8.4 26.2-18.5 53.9-35.3 75.1-71 89.8-167.9 132.8-279.9 140.3-47.5 3.2-95.7-3.2-143.6-5.8-36.1-2-72.2-5.2-108.3-7.6-18.3-1.2-28.9 6.5-33.5 25.5-28.8 118.7-44 239.5-58.9 360.5-9.4 76.2-23.6 152.2-41.9 226.8-9.9 40.5-41.5 68.4-85.2 75.4-26.1 4.2-45.5-7.1-54.3-31.5-7.4-20.6-14.3-42.1-16.1-63.7-8.6-106.3-5.1-212.3 9-318.1 7.2-53.8 11.9-107.9 18.1-161.9 4.3-37.5 10-74.9 13.5-112.5 2.8-30.4-4.1-37.5-33.2-43.3-60.1-12-120.3-23.8-180.2-37-40.7-9-72.4 5.4-99.9 33.4-36.6 37.3-77.1 69.6-125.1 90.6-58 25.3-119.5 20-179.1 10.5-86.1-13.7-154.8-59-203.7-131.6-15.2-22.5-26.2-47.9-38.1-72.5-6.7-13.8-12.6-19.1-28.8-10.9-57.2 29.1-114.2 59-173.2 84-65.8 27.8-135.6 37.6-205.5 18.1-68.1-19-120.4-62.9-163.8-117.7-11.7-14.5-23.1-29.3-41.1-52.4zm1962.4-272.7c-.8-9.4-.8-18.9-2.3-28.2-8.7-53.7-62.6-77.7-106.1-45.4-19.6 14.6-37.5 33.9-50.9 54.4-44.8 68.6-65 147.2-85.2 225.4-5.1 19.6-8.6 40.4-8.2 60.5.8 37.5 22.8 48.6 54.3 28.3 65.3-42.1 113.6-100.5 154.4-165.4 24.8-39.3 45.1-80.9 44-129.6zm-2560.8 37.9c.6-37.3-8.1-71.8-35.6-98.7-15.2-14.9-34.3-21.3-56.1-14.5-26.5 8.2-40.8 27.9-42.8 60.5-3.9 63.2 23.3 117.5 51.2 171 14.4 27.5 28.1 26.7 46.6 1.2 26-35.6 36.1-76 36.7-119.5zm-644.3-12.1c-6.9-22.9-11.5-46.8-21.3-68.3-12.6-27.4-45.1-39.7-73.8-32.2-30.4 8-42.4 22.5-39.3 59.9 2.8 32.6 10.3 65.1 18.9 96.7 6.4 23.3 16.2 46.1 27.7 67.3 15.6 28.5 31.9 28.8 47.2 1.2 21.2-38.1 37.6-78 40.6-124.6z" />
</svg>
</div>
</div>
<div class="right">
<div class="btn btn-shop">Shop</div>
<div class="btn btn-subscribe">Subscribe</div>
<div class="btn btn-login">Login</div>
</div>
</header>
I am trying to create a wave effect on a website like this where there is a main color wave (dark purple) and then lighter colored waves along the edge. I have tried positioning multiple paths with CSS position and top but cannot get them to work.
Here's my basic wave:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1440 320">
<path class="green" fill="#0b5b41" fill-opacity="1" d="M0,224L60,213.3C120,203,240,181,360,186.7C480,192,600,224,720,245.3C840,267,960,277,1080,250.7C1200,224,1320,160,1380,128L1440,96L1440,320L1380,320C1320,320,1200,320,1080,320C960,320,840,320,720,320C600,320,480,320,360,320C240,320,120,320,60,320L0,320Z"></path>
</svg>
Mybe so
Three separate waves. The color of each wave can be selected to your liking.
The app is responsive and looks the same in all modern browsers
.w1 {
fill:#0E7452;
opacity:0.4;
}
.w2 {
fill:#0E7452;
opacity:0.7;
}
.w3 {
fill:#0B5B41;
}
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1440 320" version="1.1">
<path class="w1" d="m-1.2 155.9c0 0 45.8-1.8 68.7-0.8 96.9 4.3 213.1 15.7 289.6 28.9 120 19 241.7 41.5 361.7 62.8 120 21.7 269.8 29.2 389.8 2.9C1228.6 222.9 1320 108 1380 76l60-32v224l-60 52-293-1.1H734L363.5 317.2 75.8 322.4 0 268c0 0-1.2-81.2-1.2-112.1z"/>
<path class="w2" d="m-1.2 186.8c0 0 45-1.1 67.5-2 190.8-7.9 184.4-4 297.5 2 120 5.3 241.2 42.3 361.2 63.6 120 21.7 245 23 365-3.3 120-26.7 194-95.4 290.1-145.1 20.1-10.4 60-32 60-32V294H1380 1080 720 360 60 0Z" />
<path class="w3" d="M0 224 60 213.3C120 203 228.9 182.5 348.9 188.2 468.9 193.5 600 224 720 245.3 840 267 960 277 1080 250.7 1200 224 1320 160 1380 128l60-32V320H1380 1080 720 360 60 0Z" />
</svg>