1

Apologies in advance for the wonky indentation.

I have a simple Bootstrap Grid setup like so

<div class="row justify-content-center" align="center" id="details">
    <div class="col-sm-2">
        <div class="card">
            <div class="card-body">
                <h4><?php echo getDAtimeWorked($envelope); ?></h4>
                 <h5 id=""><?php echo getDArecords($envelope); ?></h5>
                  </div>
                </div>
            </div>
            <div class="col-sm-2">
                <div class="card">
                  <div class="card-body">
                    <h4><?php echo getTNtimeWorked($envelope); ?></h4>
                    <h5 id=""><?php echo getTNrecords($envelope); ?></h5>
                  </div>
                </div>
            </div>
            <div class="col-sm-2">
                <div class="card">
                  <div class="card-body">
                    <h4><?php echo getMHtimeWorked($envelope); ?></h4>
                    <h5 id=""><?php echo getMHrecords($envelope); ?></h5>
                  </div>
                </div>
            </div>
            <div class="col-sm-2">
                <div class="card">
                  <div class="card-body">
                    <h4><?php echo getLTtimeWorked($envelope); ?></h4>
                    <h5 id=""><?php echo getLTrecords($envelope); ?></h5>
                  </div>
                </div>
            </div>
            <div class="col-sm-2">
                <div class="card">
                  <div class="card-body">
                  </div>
                </div>
            </div>
        </div>

function showDetails() {
  var x = document.getElementById("details");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}

When I click on that cell to toggle show/hide, the hidden and then shown content is no longer aligned center. How can I get it to?

My end goal for transparency is to hide that content on page load and reveal it onclick.

Mikey
  • 107
  • 2
  • 8

1 Answers1

1

In your js, you're switching it to block, x.style.display = "block" , so the class justify-content-center stops working because it's not a flex anymore.

Try x.style.display = "flex" instead.

LSE
  • 1,075
  • 1
  • 8
  • 10
  • Magic! Thank you!! Will mark as the working answer in a few minutes when the cooldown expires. – Mikey Jun 17 '21 at 01:39