0

I have this HTML layout:

<div class="container">
    <header>
        <h1>AmarCourse</h1>
        <nav>
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">About</a></li>
            </ul>
        </nav>
    </header>
    <main>
        <section class="post">
            <article>
                <h2>My First Article</h2>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. </p>
            </article>
        </section>
        <aside>
            <h2>About Me</h2>
            <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. </p>
        </aside>
    </main>
    <footer>
        <nav>
            <ul>
                <li><a href="#">Copyright</a></li>
                <li><a href="#">Terms</a></li>
            </ul>
        </nav>
        <address>Dhanmondi 15 no, Dhanmondi, Dhaka-1209.</address>
        <p>All rights reserverd</p>
    </footer>
</div>

Now, I am using the following CSS for the footer and header:

header nav ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    padding: 0;
}

footer nav ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    padding: 0;
}

You can see that both header and footer hash the same css property that's why I am writing this code:

header,
footer nav ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    padding: 0;
}

But It's showing me:

enter image description here

Should be show

enter image description here

Shibbir
  • 1,583
  • 19
  • 32

4 Answers4

2

If my understanding is correct, you are selecting only the header element and not the nav and the li inside it.

Please try the below:

header nav ul,
footer nav ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    padding: 0;
}

Hope this works

0

It works perfectly for me, with one change:

In the original CSS, header and footer nav ul have different justify-content attributes. Make sure you are using the correct selectors, as Arjun said, but you will need to leave the justify-content: center; for header.

It's probably best you leave it as it was, because that will work fine.

William
  • 199
  • 1
  • 9
0

Seems like desplay flex for header is worth. Because you wants Logo be up to the nav so just add to header flex-direction:column; justify-content:center; align-items is worth - delete this line.

Morani
  • 146
  • 10
0
header,
footer nav ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    padding: 0;
}

Here you select only the header. You should be able to use this code for it to work.

header nav ul, 
footer nav ul 
{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: center;
    padding: 0;
}
Moataz Alsayed
  • 371
  • 2
  • 11