1

So I've tried looking up similar issues other people were having with using flex-end with justify-content, but none of the solutions seem to work for me. I'm a bit new to developing website and I'm still learning the basics I guess.

I want to avoid just adding margin-left and adding a bunch of media queries because I guess it doesn't feel right?

EDIT: Sorry I should of been more specific with what I wanted. I basically want the MC# and the "talk to us" all the way at the end of the header. This is what it currently looks like website

Blockquote

JSX

 <header className={headerStyles.header}>
             <nav>
                <ul className={headerStyles.navList}>
                    <li>
                <Link className={headerStyles.title} to="/">
                    {data.site.siteMetadata.title}
                </Link>
            </li>
                    <li>
                <Link className={headerStyles.navItem} activeClassName={headerStyles.activeNavItem}  to="/">Home</Link> 
                    </li><br />
                    <li>
                <Link className={headerStyles.navItem} activeClassName={headerStyles.activeNavItem}  to="/blog">Blog</Link>
                    </li><br />
                     <li> 
                <Link className={headerStyles.navItem} activeClassName={headerStyles.activeNavItem}  to="/about">About</Link>
                    </li><br />
                     <li>
                <Link className={headerStyles.navItem} activeClassName={headerStyles.activeNavItem}  to="/contact">Contact</Link>
                    </li>

                    <li className={headerStyles.mcNum}>
                    <p>MC# 1322334</p>
                    <p className={headerStyles.vline}>Talk To Us!<br /> <a href="tel:800-888-8888">800-888-8888</a></p>
                    </li>
                </ul>
            </nav>

CSS

.header {
    position: fixed;
    padding: .5rem 5rem 0rem;
    background: white;
    box-shadow: 0px 4px 8px -4px rgba(0,0,0,0.3); 
    z-index: 500;
    width: 100%;
    display: flex;
    align-items: stretch;
    height: auto;
}

.title {  
    color: black;
    font-size: 1.5rem;
    text-decoration: none;
    margin-right: 5rem;
    float: left;
    display: table-cell;
    vertical-align: middle;
    white-space: nowrap;
    font-family: 'Lato', sans-serif;
}

.nav-list {
    display: flex;
    align-items: center;
    list-style-type: none;
    margin: 0;
    font-weight: 700;
    font-family: 'Lato', sans-serif;
}

.nav-item{
    color: black;
    font-size: 1.1rem;
    font-weight: 400;
    font-family: 'Lato', sans-serif;
    margin-right: 2.2rem;
    text-decoration: none;
}

.mcNum {
    display: flex;
    align-items: center;
    justify-items: flex-end;
    white-space: nowrap;
}
Adam Noah
  • 40
  • 6

2 Answers2

0

justify items doesn't apply to flexbox. You may be mixing apples and oranges here, and want either justify-content or align items, dependent on what you're going for. See https://css-tricks.com/snippets/css/a-guide-to-flexbox/ for a good comprehensive overview of using flexbox that I routinely return to.

Based on the edited info and viewing the page in the comment, I recommend something along these lines: Alter the structure of the HTML output to provide two <ul>'s inside the nav, one for the JSX-generated links, and other for the part you want pushed to the right. Then, alter the CSS:

nav {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

and give both <ul>'s the same styling:

.header-module--mcNum--2BWPQ {
    height: auto;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: flex-end;
    white-space: nowrap;
beltouche
  • 731
  • 6
  • 15
  • 1
    Sorry I should of been more specific with what I wanted. I basically want the MC# and the "talk to us" all the way at the end of the header. This is what it currently looks like https://wizardly-hawking-3a27a0.netlify.com/ – Adam Noah Jan 26 '20 at 02:47
  • My hero. That got me in the right direction, it's working now. Thanks! – Adam Noah Jan 26 '20 at 04:20
0

did you mean justify-content? justify-items is ignored in flexbox layouts, as it says here: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items

EDkatzen
  • 85
  • 1
  • 1
  • 9