Kevin Powell - CommunityKP-C
Kevin Powell - Community2y ago
4 replies
CDL

How to move elements inside a container? (vague, I know)

https://github.com/callum-laing/shopping-site

Apologies I tried putting this into codesandbox but it spazzed out, and codepen didn't want to do it either.

I'm trying to find out how I move the positioning of the 2 elements on the side (CDL, and the shopping cart image). I tried padding-left and padding-right on the header, but that also moves the links in the middle, is there a better alternative here that doesn't disturb spacing of others?

export default function Navbar() {
  return (
    <div className={styles.header}>
      <div>
        <h1 className={styles.title}>CDL</h1>
      </div>

      <nav className={styles.nav}>
        <Link className={styles.txt} href="/">
          Home
        </Link>
        <Link className={styles.txt} href="/shop">
          Shop
        </Link>
        <Link className={styles.txt} href="/about">
          About Us
        </Link>
      </nav>

      <Link href="/cart">
        <button className={styles.shoppingCart}>
          <span>
            <Image className={styles.cartImage} src={Logo} alt="cart logo" />
          </span>
        </button>
      </Link>
    </div>
  );
}


CSS:
    .header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 2px solid darkgrey;
    }

    .title {
        color: white;
    }

    .nav {
        display: flex;
        justify-content: center;
        align-content: center;
        gap: 50px;
        padding: 20px;
    }

    .shoppingCart {
        background-color: transparent;
        border: none;
    }

    .shoppingCart:hover {
        cursor: pointer;
    }

    .cartImage {
        filter: invert(100%);
    }

    .cartImage:hover {
        filter: none;
    }

    .txt {
        text-decoration: none;
        color: rgba(200, 200, 250);
        font-family: 'Fjalla One', sans-serif;
        letter-spacing: 4px;
    }

    .txt:hover {
        color: white;
        text-decoration: underline;
    }
image.png
Was this page helpful?