在徽标下方添加导航栏并将内容居中

Add navbar below logo and center the content

我正在尝试添加一个带有链接的导航栏,该链接应位于徽标文本下方并居中。但是我无法让它在 tablet/mobile 视图中正常工作。我有一个模型可以遵循,并且只需要使用 HTML & CSS。我试过用边距和填充来推动它,但无法让它位于中心。

感谢帮助。

Mockup

li {
  padding: 0 1.25rem;
}

p,
li {
  font-family: sans-serif;
  color: rgb(0, 0, 0);
  text-align: left;
}


/***************SITE HEADER***************/

header {
  align-items: center;
  display: flex;
  height: 4.0625rem;
  justify-content: space-between;
  width: 100%;
}

.logo {
  margin-left: 50px;
  display: inline;
  font-weight: 500;
  text-transform: uppercase;
  color: white;
}

nav {
  margin-right: 25px;
  
}

header li {
  font-weight: 300;
  display: inline;
}

a {
  color: rgb(255, 255, 255);
  text-decoration: none;
}

.intro {
float: right;
margin-top: 100px;
margin-right: 300px;
}
.intro li {
  color: rgb(255, 255, 255);
  text-align: center;
  padding: 10px;
  font-family: "Press Start 2P", sans-serif;
}


/***************MAIN***************/

main {
  align-items: center;
background-color: rgb(230, 230, 230);
  display: flex;
  height: auto;
  justify-content: center;
  margin-top: 30rem;
  position: relative;
  text-align: center;
  padding-bottom: 50px;
  padding-top: 5px;
}

img {
  width: 250px;
  height: 250px;
  overflow: hidden;
  border-radius: 100%;
  margin: -80px auto 0 ;
  border: 10px solid white;
}

#leftpic
{
margin-right: 50%;
}

#rightpic
{
  margin-left: 25%;
}

h2 {
  font-size: 25px;
  font-weight: normal;
}


.rows {
  display: grid;
  grid-auto-flow: column;
  gap: 2%;
  margin-top: 25px;
  margin-right: 80px;
  margin-left: 80px;
}

.col {
  border: 1px solid lightgrey;
  background-color: rgb(255, 255, 255);
padding: 20px;
}



/***************FOOTER***************/

footer {
  height: 9.375rem;
  margin-top: 1.25rem;
  margin-left: 250px;
}
 
small  {
  color:white;
}

.left{
  float: left;
  width: 33.333%;
  }
  .right{
    float: right;
    width: 33.333%;
  }
  .centered{
    display: inline-block;
    width: 33.333%;
  }


/***************MEDIA QUERIES***************/



/***************Laptop***************/
@media only screen and (max-width: 1024px) {

  #rightpic
  {
    margin-left: 20%;
  }

  #leftpic
  {
    margin-left: -20%;
  }
  img
  {
    width: 90%;
    height: 15%;
  }

/***************Tablet***************/
@media only screen and (max-width: 768px) {

  img
  {
    width: 40%;
    height: 5%;
  }
  
  .rows {
    display: inline-block;
  }

  .col {
    margin-bottom: 20%;
    
  }

  #leftpic {
margin: auto;
margin-top: -15%;
  }

  #rightpic {
    margin: auto;
    margin-top: -15%;
  }


footer {
  margin-left: 20%;
    }

  .logo {
    white-space: nowrap;
margin: 0;
padding-left: 30%;
text-align: center;
width: 100%;
  }

  nav {
    white-space: nowrap;
    padding-right: 80%;
    text-align: center;
  }

  header li {
  margin: 0;
padding-top: -80em;
text-align: center;
overflow: hidden;
  }

  .intro {
    padding-top: 10%;
    font-size: 70%;
    text-align: center;
  }



/***************Stor mobil***************/
@media only screen and (max-width: 425px) {
  header li {
font-size: 80%;
padding: auto;
margin: auto;
}

  
/***************Medelstor mobil***************/
  @media only screen and (max-width: 375px) {
 li {
 font-size: 80%;
}
.banner {
background-position: -200px !important; 
}

/***************Smal mobil***************/
@media only screen and (max-width: 320px) {
li {
 font-size: 60%;
}
h1 {
font-size: 90% !important;
}

.banner {
background-position: -200px !important; 
}
    <header>
        <h1 class="logo">‍ Ett Namn</h1>

          <!-- Meny -->
          <nav>
            <ul>
           <li><a href="index.html"> Hem</a></li>
          <li><a href="portfolio.html"> Portfolio</a></li>
          <li><a href="rapport.html"> Rapport</a></li>
          </li>
          </ul>
      </nav>
  
    </header>

    <div class="intro">
      <h1><ul style="list-style-type:none;">
        <li> ️ Webbsidor</li>
        <li> Webbappar</li>
        <li> Datorspel</li>
      </ul></h1>
    </div>

      <!-- Main -->
      <main>
          <div class="rows">
            <div class="col">
              <img id="leftpic" src="https://images.unsplash.com/photo-1612099452850-ed8efe7d58ff?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1600&q=80">
              <h2>Kodar webbsidor och webbappar.</h2>
              <p>Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit​​, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium. Qui animated corpse, cricket bat max brucks terribilem incessu zomby. The voodoo sacerdos flesh eater, suscitat mortuos comedere carnem virus. Zonbi tattered for solum oculi eorum defunctis go lum cerebro. Nescio brains an Undead zombies. Sicut malus putrid voodoo horror. Nigh tofth eliv ingdead.
              Cum horribilem walking dead resurgere de crazed sepulcris creaturis, zombie sicut de grave feeding iride et serpens. Pestilentia, shaun ofthe dead scythe animated corpses ipsa screams. Pestilentia est plague haec decaying ambulabat mortuos. Sicut zeder apathetic malus voodoo. Aenean a dolor plan et terror soulless vulnerum contagium accedunt, mortui iam vivam unlife. Qui tardius moveri, brid eof reanimator sed in magna copia sint terribiles undeath legionis. Alii missing oculis aliorum sicut serpere crabs nostram. Putridi braindead odores kill and infect, aere implent left four dead.</p>
              <br>
              <p>Cum horribilem walking dead resurgere de crazed sepulcris creaturis, zombie sicut de grave feeding iride et serpens. Pestilentia, shaun ofthe dead scythe animated corpses ipsa screams. Pestilentia est plague haec decaying ambulabat mortuos. Sicut zeder apathetic malus voodoo. Aenean a dolor plan et terror soulless vulnerum contagium accedunt, mortui iam vivam unlife. Qui tardius moveri, brid eof reanimator sed in magna copia sint terribiles undeath legionis. Alii missing oculis aliorum sicut serpere crabs nostram. Putridi braindead odores kill and infect, aere implent left four dead.</p>
            </div>
            

              <div class="col">
                <img src="https://images.unsplash.com/photo-1612099452850-ed8efe7d58ff?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1600&q=80">
                <h2>Webmaster student som kommer från Umeå.</h2>
                <p>Bacon ipsum dolor amet enim nisi jowl, beef aliquip ground round cupim tempor pastrami chislic magna adipisicing. Ex aliquip tenderloin swine incididunt do enim. Leberkas hamburger ex labore, ipsum esse porchetta. Ut voluptate biltong cupim t-bone meatloaf aute tri-tip rump filet mignon do ullamco laborum ham hock minim.
              In eu voluptate, ullamco bacon in meatball minim biltong reprehenderit boudin aliquip ball tip ut sausage. Cupim beef ribs turducken brisket id proident swine aute mollit meatball venison meatloaf boudin. Kielbasa voluptate pig, ham hock pork belly tempor excepteur sirloin fatback chuck spare ribs mollit. Jerky jowl ex, pariatur aliquip tri-tip beef tail minim shankle.</p>
              <br>
              <p>In eu voluptate, ullamco bacon in meatball minim biltong reprehenderit boudin aliquip ball tip ut sausage. Cupim beef ribs turducken brisket id proident swine aute mollit meatball venison meatloaf boudin. Kielbasa voluptate pig, ham hock pork belly tempor excepteur sirloin fatback chuck spare ribs mollit. Jerky jowl ex, pariatur aliquip tri-tip beef tail minim shankle.</p>
            </div>

            <div class="col">
              <img  id="rightpic" src="https://images.unsplash.com/photo-1612099452850-ed8efe7d58ff?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1600&q=80">
              <h2>Producerar spel till PC och Steam Deck.</h2>
              <p>Godard shoreditch aesthetic, deep v organic austin tofu. Farm-to-table tumeric fixie tattooed photo booth ethical banh mi narwhal iceland 90's bitters messenger bag. Austin gentrify put a bird on it live-edge, cardigan man braid vice distillery activated charcoal heirloom sriracha snackwave yr venmo unicorn. Brooklyn paleo beard live-edge tbh, unicorn fingerstache gochujang occupy sustainable mlkshk poke street art fanny pack. Prism brunch YOLO, authentic tbh polaroid fingerstache narwhal typewriter green juice kitsch gochujang crucifix twee.</p>
              <br>
              <p>Jean shorts portland hella jianbing four dollar toast wolf migas. Polaroid cronut sriracha, post-ironic plaid fashion axe austin irony actually stumptown celiac whatever hexagon hoodie coloring book. Kombucha keytar hella austin cardigan woke you probably haven't heard of them pinterest sartorial jianbing microdosing tbh. Kickstarter paleo asymmetrical, vegan pop-up you probably haven't heard of them fam microdosing man braid affogato. Banjo cliche small batch salvia edison bulb prism microdosing 8-bit before they sold out chillwave truffaut drinking vinegar. Cliche intelligentsia butcher taxidermy occupy chambray leggings mlkshk pug wayfarers. Cornhole irony thundercats, poutine wayfarers heirloom cardigan.</p>
              </div>
          </div>

      </main>

    <!-- Footer -->
    <footer>

    <small class="left"> <h3>Adress</h3>
    <br /><br />Kungsgatan 108
    <br />90332 Umeå</small>

    <small class="right"> <h3>Telefon</h3>
      <br /><br />0702815540</small>

    <small class="centered"><h3>E-Post</h3>
      <br /><br />Mail.com</small>
    </footer>

您快完成了,但是您忘记在响应式视图中删除 display: flex 将其更改为 display:block 将解决您的问题

/***************GENERAL***************/

html, body {
  color: #434242;
  font-family: sans-serif;
  font-size: 100%;
  background-image: linear-gradient( rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6) ), url("https://images.unsplash.com/photo-1612099452850-ed8efe7d58ff?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1600&q=80");
  background-size: cover;
  margin:0;
padding:0;
}

li {
  padding: 0 1.25rem;
}

p,
li {
  font-family: sans-serif;
  color: rgb(0, 0, 0);
  text-align: left;
}


/***************SITE HEADER***************/

header {
  align-items: center;
  display: flex;
  height: 4.0625rem;
  justify-content: space-between;
  width: 100%;
}

.logo {
  margin-left: 50px;
  display: inline;
  font-weight: 500;
  text-transform: uppercase;
  color: white;
}

nav {
  margin-right: 25px;
  
}

header li {
  font-weight: 300;
  display: inline;
}

a {
  color: rgb(255, 255, 255);
  text-decoration: none;
}

.intro {
float: right;
margin-top: 100px;
margin-right: 300px;
}
.intro li {
  color: rgb(255, 255, 255);
  text-align: center;
  padding: 10px;
  font-family: "Press Start 2P", sans-serif;
}


/***************MAIN***************/

main {
  align-items: center;
background-color: rgb(230, 230, 230);
  display: flex;
  height: auto;
  justify-content: center;
  margin-top: 30rem;
  position: relative;
  text-align: center;
  padding-bottom: 50px;
  padding-top: 5px;
}

img {
  width: 250px;
  height: 250px;
  overflow: hidden;
  border-radius: 100%;
  margin: -80px auto 0 ;
  border: 10px solid white;
}

#leftpic
{
margin-right: 50%;
}

#rightpic
{
  margin-left: 25%;
}

h2 {
  font-size: 25px;
  font-weight: normal;
}


.rows {
  display: grid;
  grid-auto-flow: column;
  gap: 2%;
  margin-top: 25px;
  margin-right: 80px;
  margin-left: 80px;
}

.col {
  border: 1px solid lightgrey;
  background-color: rgb(255, 255, 255);
padding: 20px;
}



/***************FOOTER***************/

footer {
  height: 9.375rem;
  margin-top: 1.25rem;
  margin-left: 250px;
}
 
small  {
  color:white;
}

.left{
  float: left;
  width: 33.333%;
  }
  .right{
    float: right;
    width: 33.333%;
  }
  .centered{
    display: inline-block;
    width: 33.333%;
  }


/***************MEDIA QUERIES***************/



/***************Laptop***************/
@media only screen and (max-width: 1024px) {

  #rightpic
  {
    margin-left: 20%;
  }

  #leftpic
  {
    margin-left: -20%;
  }
  img
  {
    width: 90%;
    height: 15%;
  }

/***************Tablet***************/
@media only screen and (max-width: 768px) {

  img
  {
    width: 40%;
    height: 5%;
  }
  
  .rows {
    display: inline-block;
  }

  .col {
    margin-bottom: 20%;
    
  }

  #leftpic {
margin: auto;
margin-top: -15%;
  }

  #rightpic {
    margin: auto;
    margin-top: -15%;
  }


footer {
  margin-left: 20%;
    }

  .logo {
margin: 0 auto;
    float: none;
display: block;
text-align: center;
width: 100%;
  }
  header {
    display: block;
  }
  nav {
    display: block;
    text-align: center;
  }
  }
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="stylesheet">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
    <title>Ett Namn</title>
  </head>
  <body>

    <!-- Sidhuvud -->
    <header>
        <h1 class="logo">‍ Ett Namn</h1>

          <!-- Meny -->
          <nav>
            <ul>
           <li><a href="index.html"> Hem</a></li>
          <li><a href="portfolio.html"> Portfolio</a></li>
          <li><a href="rapport.html"> Rapport</a></li>
          </li>
          </ul>
          </div>
      </nav>
    </div>
  </div>
  
    </header>

    <div class="intro">
      <h1><ul style="list-style-type:none;">
        <li> ️ Webbsidor</li>
        <li> Webbappar</li>
        <li> Datorspel</li>
      </ul></h1>
    </div>

      <!-- Main -->
      <main>
          <div class="rows">
            <div class="col">
              <img id="leftpic" src="https://images.unsplash.com/photo-1612099452850-ed8efe7d58ff?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1600&q=80">
              <h2>Kodar webbsidor och webbappar.</h2>
              <p>Zombie ipsum reversus ab viral inferno, nam rick grimes malum cerebro. De carne lumbering animata corpora quaeritis. Summus brains sit​​, morbo vel maleficia? De apocalypsi gorger omero undead survivor dictum mauris. Hi mindless mortuis soulless creaturas, imo evil stalking monstra adventus resi dentevil vultus comedat cerebella viventium. Qui animated corpse, cricket bat max brucks terribilem incessu zomby. The voodoo sacerdos flesh eater, suscitat mortuos comedere carnem virus. Zonbi tattered for solum oculi eorum defunctis go lum cerebro. Nescio brains an Undead zombies. Sicut malus putrid voodoo horror. Nigh tofth eliv ingdead.
              Cum horribilem walking dead resurgere de crazed sepulcris creaturis, zombie sicut de grave feeding iride et serpens. Pestilentia, shaun ofthe dead scythe animated corpses ipsa screams. Pestilentia est plague haec decaying ambulabat mortuos. Sicut zeder apathetic malus voodoo. Aenean a dolor plan et terror soulless vulnerum contagium accedunt, mortui iam vivam unlife. Qui tardius moveri, brid eof reanimator sed in magna copia sint terribiles undeath legionis. Alii missing oculis aliorum sicut serpere crabs nostram. Putridi braindead odores kill and infect, aere implent left four dead.</p>
              <br>
              <p>Cum horribilem walking dead resurgere de crazed sepulcris creaturis, zombie sicut de grave feeding iride et serpens. Pestilentia, shaun ofthe dead scythe animated corpses ipsa screams. Pestilentia est plague haec decaying ambulabat mortuos. Sicut zeder apathetic malus voodoo. Aenean a dolor plan et terror soulless vulnerum contagium accedunt, mortui iam vivam unlife. Qui tardius moveri, brid eof reanimator sed in magna copia sint terribiles undeath legionis. Alii missing oculis aliorum sicut serpere crabs nostram. Putridi braindead odores kill and infect, aere implent left four dead.</p>
            </div>
            

              <div class="col">
                <img src="https://images.unsplash.com/photo-1612099452850-ed8efe7d58ff?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1600&q=80">
                <h2>Webmaster student som kommer från Umeå.</h2>
                <p>Bacon ipsum dolor amet enim nisi jowl, beef aliquip ground round cupim tempor pastrami chislic magna adipisicing. Ex aliquip tenderloin swine incididunt do enim. Leberkas hamburger ex labore, ipsum esse porchetta. Ut voluptate biltong cupim t-bone meatloaf aute tri-tip rump filet mignon do ullamco laborum ham hock minim.
              In eu voluptate, ullamco bacon in meatball minim biltong reprehenderit boudin aliquip ball tip ut sausage. Cupim beef ribs turducken brisket id proident swine aute mollit meatball venison meatloaf boudin. Kielbasa voluptate pig, ham hock pork belly tempor excepteur sirloin fatback chuck spare ribs mollit. Jerky jowl ex, pariatur aliquip tri-tip beef tail minim shankle.</p>
              <br>
              <p>In eu voluptate, ullamco bacon in meatball minim biltong reprehenderit boudin aliquip ball tip ut sausage. Cupim beef ribs turducken brisket id proident swine aute mollit meatball venison meatloaf boudin. Kielbasa voluptate pig, ham hock pork belly tempor excepteur sirloin fatback chuck spare ribs mollit. Jerky jowl ex, pariatur aliquip tri-tip beef tail minim shankle.</p>
            </div>

            <div class="col">
              <img  id="rightpic" src="https://images.unsplash.com/photo-1612099452850-ed8efe7d58ff?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1600&q=80">
              <h2>Producerar spel till PC och Steam Deck.</h2>
              <p>Godard shoreditch aesthetic, deep v organic austin tofu. Farm-to-table tumeric fixie tattooed photo booth ethical banh mi narwhal iceland 90's bitters messenger bag. Austin gentrify put a bird on it live-edge, cardigan man braid vice distillery activated charcoal heirloom sriracha snackwave yr venmo unicorn. Brooklyn paleo beard live-edge tbh, unicorn fingerstache gochujang occupy sustainable mlkshk poke street art fanny pack. Prism brunch YOLO, authentic tbh polaroid fingerstache narwhal typewriter green juice kitsch gochujang crucifix twee.</p>
              <br>
              <p>Jean shorts portland hella jianbing four dollar toast wolf migas. Polaroid cronut sriracha, post-ironic plaid fashion axe austin irony actually stumptown celiac whatever hexagon hoodie coloring book. Kombucha keytar hella austin cardigan woke you probably haven't heard of them pinterest sartorial jianbing microdosing tbh. Kickstarter paleo asymmetrical, vegan pop-up you probably haven't heard of them fam microdosing man braid affogato. Banjo cliche small batch salvia edison bulb prism microdosing 8-bit before they sold out chillwave truffaut drinking vinegar. Cliche intelligentsia butcher taxidermy occupy chambray leggings mlkshk pug wayfarers. Cornhole irony thundercats, poutine wayfarers heirloom cardigan.</p>
              </div>
          </div>

      </main>

    <!-- Footer -->
    <footer>

    <small class="left"> <h3>Adress</h3>
    <br /><br />Kungsgatan 108
    <br />90332 Umeå</small>

    <small class="right"> <h3>Telefon</h3>
      <br /><br />0702815540</small>

    <small class="centered"><h3>E-Post</h3>
      <br /><br />Mail.com</small>
    </footer>
  </body>
</html>