Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Remove the space between 2 elements under each other using flex

I have a side-bar with 2 links.
The active route gets a mirrored element in the side-bar like this (see the about link):

Screenshot of side-bar

What I want is to remove the gap between the 2 Abouts.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Here is the html for the links:

  <div id="sideBarLinks">
            <div className="sidebar-link-singlewrap">
              <Link to="/about">About</Link>
              {location.pathname === '/about' ? <p className="upside-down-p">About</p> : null }
            </div>
            <div className="sidebar-link-singlewrap">
              <Link to="/">Home</Link>
              {location.pathname === '/' ? <p className="upside-down-p">Home</p> : null }
            </div>
            <HeaderSearch />
          </div>

And here is my css for the links:

      #sideBarLinks {
        display: none;
        flex-direction: column;
        gap: 2rem;
        padding-left: 10px;
        .sidebar-link-singlewrap {
          display: flex;
          flex-direction: column;
          a {
            text-decoration: none;
            color: black;
          }
          p {
            margin: 0;
            transform: rotateX(180);
          }
        }
      }

EDIT:
Here is the snippit:

div {
  display: flex;
  flex-direction: column;
}
a {
  margin: 0;
}
p {
  margin: 0;
  transform: rotateX(180deg);
}
<div>
  <a>Test</a>
  <p>Test</p>
</div>

>Solution :

p.upside-down-p {
    margin-top: 0;
    margin-bottom: 0;
    line-height: 8px; //adjust according to your requirement
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading