skip to Main Content

columns need to be the whole height of the row but the content (text) still needs to be vertically centered.

<div class="row fixed-bottom mobile-navbar align-items-center">
    <router-link to="/" class="col h-100">Home</router-link>
    <router-link to="/scan" class="col h-100">Scan</router-link>
    <router-link to="/account" class="col h-100">Account</router-link>
  </div>

how do I do this?

I’ve tried to place spans inside the a elements and use py-auto, but this doesn’t seem to do the trick.

2

Answers


  1. Chosen as BEST ANSWER

    I fixed the issue: I had a class on my row called, mobile-navbar that gave a fixed height on the element, making it annoying to center the children. I removed the fixed height and let the children decide the height of the parent by using padding leaving them in the center vertically.


  2. h-100 takes the 100% size of the object it is in, so it cannot be centered because it is 100% vertical.
    Delete the h-100s and give the container the following css or classes.

    must be:

    <div class="row h-100 align-items-center" > //must be bigger than router height you can write min height:200px;
    <router-link to="/" class="col ">Home</router-link>
    <router-link to="/scan" class="col ">Scan</router-link>
    <router-link to="/account" class="col">Account</router-link>
    </div>
    

    alternative:

      <!doctype html>
      <html lang="en">
        <head>
          <meta charset="utf-8">
          <meta name="viewport" content="width=device-width, initial-scale=1">
          <title>Bootstrap demo</title>
          <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
        </head>
        <body>
          <h1>Hello, world!</h1>
          <div class="row d-flex align-items-center border" style="height:500px;">
            <div class="col border">1</div>
            <div class="col border">2</div>
            <div class="col border">3</div>
          </div>
          <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
        </body>
      </html>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search