0

I'm trying to vertically center a row of divs contenaining inside pictures without moving the text. I tried doing it by using align-content: center, but it didin't work... The divs contenaining the pictures are located at the Homepage and Supports tabs.

The code:

function openTab(event, pageName) {
  // Declare all variables
  var i, tabcontent, tablinks;
  // Get all elements with class="tabcontent" and hide them
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }

  // Get all elements with class="tablinks" and remove the class "active"
  tablinks = document.getElementsByClassName("tablinks");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].className = tablinks[i].className.replace(" active", "");
  }
  // Show the current tab, and add an "active" class to the button that opened the tab
  document.getElementById(pageName).style.display = "block";
  event.currentTarget.className += " active";
}
// Get the element with id="DefaultOpen" and click on it
document.getElementById("TabLinks_DefaultOpen").click();
body {
  background-color: white;
}

h1 {
  text-align: center;
}

input,
select,
textarea {
  width: 100%;
  padding: 6px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

label {
  padding: 12px 12px 12px 0;
  display: flex;
  flex-direction: column;
}

.Horizontal_Tab button {
  float: left;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 14px 16px;
  transition: 0.3s;
  background-color: inherit;
}

.Horizontal_Tab button:hover {
  background-color: #ddd;
}

.Horizontal_Tab button.active {
  background-color: #ccc;
}

.Horizontal_Tab {
  overflow: hidden;
  float: left;
  border: 1px solid black;
  background-color: #f2f2f2;
  height: auto;
  display: flex;
  flex-flow: row;
  width: 100%;
  display: flex;
  justify-content: space-around;
}

.tabcontent {
  animation: fadeEffect 1s;
  top: 15%;
  display: flex;
  justify-content: center;
}

@keyframes fadeEffect {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

._Links {
  display: flex;
  flex-flow: row wrap;
}

.Dapp_Links {
  flex: 15%;
  padding: 5px;
  border: 2px solid black;
  display: flex;
  justify-content: center;
}

.Dapp_Links img {
  width: 50%;
  height: auto;
  cursor: pointer;
}

.Support_Links {
  flex: 30%;
  padding: 5px;
  border: 2px solid black;
  display: flex;
  justify-content: center;
}

.Support_Links img {
  width: 30%;
  height: auto;
  cursor: pointer;
}
<body>

  <div id="HorizontalTab" class="Horizontal_Tab">
    <button id="TabLinks_DefaultOpen" class="tablinks" onclick="openTab(event, 'DefaultOpen')">Homepage</button>
    <button id="TabLinks_OrderCreateShipStock" class="tablinks" onclick="openTab(event, 'OrderCreateShipStock')">Orders</button>
    <button id="TabLinks_OrderList" class="tablinks" onclick="openTab(event, 'OrderList')">Orders list</button>
    <button id="TabLinks_OrderWarehouse" class="tablinks" onclick="openTab(event, 'OrderWarehouse')">Warehouse
            list</button>
    <button id="TabLinks_OrderShipment" class="tablinks" onclick="openTab(event, 'OrderShipment')">Shipment
            list</button>
    <button id="TabLinks_OrderOutOfCompliance" class="tablinks" onclick="openTab(event, 'OrderOutOfCompliance')">Out
            of compliance
            list</button>
    <button id="TabLinks_Support" class="tablinks" onclick="openTab(event, 'Support')">Supports</button>
  </div>

  <div id="DefaultOpen" class="tabcontent">
    <h1>Welcome *Account*! You're now logged in as a *Position* at SupChain</h1>
    <div id="Links" class="_Links">
      <div id="DappLinksOrders" class="Dapp_Links">
        <img src="">
      </div>
      <div id="DappLinksWarehouse" class="Dapp_Links">
        <img src="">
      </div>
      <div id="DappLinksShipments" class="Dapp_Links">
        <img src="">
      </div>
      <div id="DappLinksOutOfCompliance" class="Dapp_Links">
        <img src="">
      </div>
      <div id="DappLinksSuppots" class="Dapp_Links">
        <img src="">
      </div>
    </div>
  </div>

  <div id="OrderCreateShipStock" class="tabcontent">
    <h2>Orders</h2>
  </div>

  <div id="OrderList" class="tabcontent">
    <h2>Orders list</h2>
  </div>

  <div id="OrderWarehouse" class="tabcontent">
    <h2>Warehouse</h2>
  </div>

  <div id="OrderShipment" class="tabcontent">
    <h2>Shipments</h2>
  </div>

  <div id="OrderOutOfCompliance" class="tabcontent">
    <h2>Out of compliance</h2>
  </div>

  <div id="Support" class="tabcontent">
    <h1>A problem ? Contact us !</h1>
    <div id="Links" class="_Links">
      <div id="SupportLinksPhone" class="Support_Links">
        <img src="">
      </div>
      <div id="SupportLinksEmail" class="Support_Links">
        <img src="">
      </div>
      <div id="SupportLinksChat" class="Support_Links">
        <img src="">
      </div>
    </div>
  </div>
</body>

I thank in advance anybody who will take the time to help me.

Tameiki
  • 35
  • 9
  • 2
    Hey can you clarify something? So you want the text in those boxes to be bellow the pictures? – Yuran Pereira Aug 19 '20 at 16:17
  • 1
    which elements do you want to vertically center? the black empty boxes from your example? – Capagris Aug 19 '20 at 16:26
  • 1
    In any event, they need a parent flex element against which to be centered vertically, and this parent element needs a calculated height, either a fixed measurement directly, or, a 100% (for example) of a grandparent with a fixed with or something like 100vh – Capagris Aug 19 '20 at 16:48
  • @YuranPereira What I need to be vertically centered are the black boxes that will afterwards contains the pictures. – Tameiki Aug 19 '20 at 16:56

1 Answers1

1

Try this. Inspired by the top answere here.

function openTab(event, pageName) {
  // Declare all variables
  var i, tabcontent, tablinks;
  // Get all elements with class="tabcontent" and hide them
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }

  // Get all elements with class="tablinks" and remove the class "active"
  tablinks = document.getElementsByClassName("tablinks");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].className = tablinks[i].className.replace(" active", "");
  }
  // Show the current tab, and add an "active" class to the button that opened the tab
  document.getElementById(pageName).style.display = "block";
  event.currentTarget.className += " active";
}
// Get the element with id="DefaultOpen" and click on it
document.getElementById("TabLinks_DefaultOpen").click();
body {
  background-color: white;
}

h1 {
  text-align: center;
}

input,
select,
textarea {
  width: 100%;
  padding: 6px;
  border: 1px solid #ccc;
  border-radius: 5px;
}

label {
  padding: 12px 12px 12px 0;
  display: flex;
  flex-direction: column;
}

.Horizontal_Tab button {
  float: left;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 14px 16px;
  transition: 0.3s;
  background-color: inherit;
}

.Horizontal_Tab button:hover {
  background-color: #ddd;
}

.Horizontal_Tab button.active {
  background-color: #ccc;
}

.Horizontal_Tab {
  overflow: hidden;
  float: left;
  border: 1px solid black;
  background-color: #f2f2f2;
  height: auto;
  display: flex;
  flex-flow: row;
  width: 100%;
  display: flex;
  justify-content: space-around;
}

.tabcontent {
  animation: fadeEffect 1s;
  top: 15%;
  display: flex;
  justify-content: center;
}

@keyframes fadeEffect {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

._Links {
  display: table-cell;
  vertical-align: middle;
  border: 10px solid black;
  padding-left: 25px;
}

.outer {
  display: table;
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
}

.Dapp_Links {
  float:left; 
  width: 18%;
  padding: 5px;
  border: 2px solid black;
  justify-content: center;
}

.Dapp_Links img {
  width: 50%;
  height: auto;
  cursor: pointer;
}

.Support_Links {
  flex: 30%;
  padding: 5px;
  border: 2px solid black;
  display: flex;
  justify-content: center;
}

.Support_Links img {
  width: 30%;
  height: auto;
  cursor: pointer;
}
<body>

  <div id="HorizontalTab" class="Horizontal_Tab">
    <button id="TabLinks_DefaultOpen" class="tablinks" onclick="openTab(event, 'DefaultOpen')">Homepage</button>
    <button id="TabLinks_OrderCreateShipStock" class="tablinks" onclick="openTab(event, 'OrderCreateShipStock')">Orders</button>
    <button id="TabLinks_OrderList" class="tablinks" onclick="openTab(event, 'OrderList')">Orders list</button>
    <button id="TabLinks_OrderWarehouse" class="tablinks" onclick="openTab(event, 'OrderWarehouse')">Warehouse
            list</button>
    <button id="TabLinks_OrderShipment" class="tablinks" onclick="openTab(event, 'OrderShipment')">Shipment
            list</button>
    <button id="TabLinks_OrderOutOfCompliance" class="tablinks" onclick="openTab(event, 'OrderOutOfCompliance')">Out
            of compliance
            list</button>
    <button id="TabLinks_Support" class="tablinks" onclick="openTab(event, 'Support')">Supports</button>
  </div>

  <div id="DefaultOpen" class="tabcontent">
    <h1>Welcome *Account*! You're now logged in as a *Position* at SupChain</h1>
    <div class="outer">
      <div id="Links" class="_Links">
        <div id="DappLinksOrders" class="Dapp_Links">
          <img src="">
        </div>
        <div id="DappLinksWarehouse" class="Dapp_Links">
          <img src="">
        </div>
        <div id="DappLinksShipments" class="Dapp_Links">
          <img src="">
        </div>
        <div id="DappLinksOutOfCompliance" class="Dapp_Links">
          <img src="">
        </div>
        <div id="DappLinksSuppots" class="Dapp_Links">
          <img src="">
        </div>
      </div>
    </div>
  </div>

  <div id="OrderCreateShipStock" class="tabcontent">
    <h2>Orders</h2>
  </div>

  <div id="OrderList" class="tabcontent">
    <h2>Orders list</h2>
  </div>

  <div id="OrderWarehouse" class="tabcontent">
    <h2>Warehouse</h2>
  </div>

  <div id="OrderShipment" class="tabcontent">
    <h2>Shipments</h2>
  </div>

  <div id="OrderOutOfCompliance" class="tabcontent">
    <h2>Out of compliance</h2>
  </div>

  <div id="Support" class="tabcontent">
    <h1>A problem ? Contact us !</h1>
    <div id="Links" class="_Links">
      <div id="SupportLinksPhone" class="Support_Links">
        <img src="">
      </div>
      <div id="SupportLinksEmail" class="Support_Links">
        <img src="">
      </div>
      <div id="SupportLinksChat" class="Support_Links">
        <img src="">
      </div>
    </div>
  </div>
</body>
Lachlan
  • 36
  • 3