Double Gradients?

Joined
Jul 3, 2025
Messages
1
Reaction score
0
Hello,

I have a linear gradient which I quite like on a website. However, I don't like the sharp cutoff at the bottom. I know I have some options - I can extend the section so I never see the cutoff, or I can do a diagonal fade... but neither of these solutions are satisfactory...

Is there a way to create that smooth fading both top to bottom just like I have already implemented from right to left? I took a screenshot of what it looks like:

 
Joined
Jul 4, 2023
Messages
609
Reaction score
81
IMHO, you could make the main background a gradient that fades to the darker color towards the top right corner - where your menu is - so that area is already mostly the final gradient color. Then just give the menu a transparent background, and it will naturally blend with the gradient underneath. This way, you avoid any hard cutoff and keep things clean without needing diagonal fades or section tricks.

Go for something like this:
HTML:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <style>
      body {
        --margin: 1em;

        margin: var(--margin);
        padding: 0;
        font: 400 .9rem/1 system-ui, monospace, sans-serif;
        height: calc(100vh - (2 * var(--margin)));
        background: linear-gradient(to top right, #fce4b5, #ffe4b5, #333);
        color: white;
      }
      .menu-toggle {
        position: absolute;
        top: 0;
        right: 0;
        font-size: 28px;
        background: none;
        border: none;
        color: white;
        cursor: pointer;
      }
      .menu {
        position: fixed;
        top: 2em;
        right: 1em;
        width: 200px;
        background: none;
        display: flex;
        flex-direction: column;
        gap: 1em;
        transform: translateX(calc(100% + (2 * var(--margin))));
        opacity: 0;
        transition: all 300ms ease;
        z-index: 9999;
      }
      .menu a {
        text-decoration: none;
        color: white;
        font-size: 18px;
        font-weight: bold;
      }
      .menu.open {
        transform: translateX(0);
        opacity: 1;
      }
      .hide {
        display: none;
      }
    </style>
  </head>
  <body>
    <button class="menu-toggle" id="menuToggle">☰</button>
    <nav class="menu" id="sideMenu">
      <button class="menu-toggle" id="menuClose">✕</button>
      <a href="#">Home</a>
      <a href="#">About</a>
      <a href="#">Projects</a>
      <a href="#">Contact</a>
    </nav>

    <script>
      const menuToggle = document.getElementById('menuToggle'),
            menuClose = document.getElementById('menuClose'),
            sideMenu = document.getElementById('sideMenu');

      menuToggle.addEventListener('click', () => {
        sideMenu.classList.add('open');
        menuToggle.classList.add('hide');
      });

      menuClose.addEventListener('click', () => {
        sideMenu.classList.remove('open');
        menuToggle.classList.remove('hide');
      });
    </script>
  </body>
</html>
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,470
Messages
2,571,809
Members
48,797
Latest member
PeterSimpson
Top