Expanding Vue Tabs with Bootstrap: Manipulating tab-content to perfectly fill parent height

On my webpage, I have implemented a tabs component called b-tabs. This component is enclosed within a parent div with a specific height.

I am trying to make the content of the tabs take up the full remaining height of the parent component.

https://i.sstatic.net/CmtLw.png

The structure of my tabs is simple and straightforward:

<div class="h-100">
    <b-tabs content-class="mt-3 h-100">
        <b-tab title="First" active>
            <div class="tab-content">I'm the first tab</div>
        </b-tab>
        <b-tab title="Second">
            <div class="tab-content">I'm the second tab</div>
        </b-tab>
        <b-tab title="Third">
            <div class="tab-content">I'm the third tab!</div>
        </b-tab>
    </b-tabs>
</div>

Upon examining the DOM structure, I attempted to set height: 100% for the following classes:

.tabs, .tab-pane, .tab-content, .my-tab-content {
    height: 100%;
}

However, this approach caused content overflow as the content div is a sibling to the tabs bar, resulting in it taking up 100% of the parent container's height.

I have considered calculating the height of the tabs bar and adjusting the content height using height: calc(100% - **px), but I believe there might be a more elegant solution available.

Explore the codesandbox example: https://codesandbox.io/s/optimistic-thunder-nwmzu

Answer №1

If you want to make the tabs more flexible, I recommend using the display: flex property and then applying the flex-grow-1 utility class. This will allow the tabs to fill up all the available space within the flex container.

new Vue({
  el: '#app'
})
.tabs-container {
  height: 400px;
  background: #d8d8d8;
}

.tab-pane {
  height: 100%;
}

.my-tab-content {
  min-height: 100%;
  background: rgba(80, 10, 10, 0.5);
}
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a1c3ceced5d2d5d3c0d18cd7d4c4e1938f93908f93">[email protected]</a>/dist/bootstrap-vue.min.css" />
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c4b2b1a184f6eaf2eaf6">[email protected]</a>/dist/vue.min.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="accec3c3d8dfd8decddc81dad9c9ec9e829e9d829e">[email protected]</a>/dist/bootstrap-vue.min.js"></script>


<div id="app" class="p-3">
  <div class="tabs-container">
    <b-tabs class="h-100 d-flex flex-column" content-class="mt-3 flex-grow-1">
      <b-tab title="First" active>
        <div class="my-tab-content">
          See at the bottom: The content of tabs overflows container
        </div>
      </b-tab>
      <b-tab title="Second">
        <div class="my-tab-content">I'm the second tab</div>
      </b-tab>
      <b-tab title="Third">
        <div class="my-tab-content">I'm the third tab!</div>
      </b-tab>
    </b-tabs>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How can I implement a jQuery slide down effect for a specific individual instance?

Whenever I click on the "Share your thoughts" button, the comments block slides down for every section instead of just the particular section I clicked on. Is there a way to make it so that only a single block slides down when the button is clicked, regard ...

Managing multiple sockets within a Vue application

Currently, my Vue application utilizes Vue-native-socket to communicate with a single socket. However, I now require the ability for my app to monitor multiple sockets simultaneously. Unfortunately, the documentation for Vue-native-socket does not provide ...

Guide on integrating database information into an array with Vue.js

I'm having trouble retrieving data from Firestore and applying it as my array. I expect to see objects in the console but nothing is showing up. Should the method be called somewhere in the code? My method created() is functioning, but only when I han ...

Vertical Positioning of Tabs in Materialize CSS

My current challenge involves creating vertical tabs using materialize CSS, specifically in regards to positioning. The desired outcome is for the content to align at the same level when clicking on TAB 3. An example of the expected result can be seen in t ...

Guide on dragging and dropping without losing the item, allowing for continuous drag and drop functionality

function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("text", ev.target.id); } function drop(ev) { ev.preventDefault(); var data = ev.dataTransfer.getData("text"); ev.target.appendChild(document.getElementB ...

How do I incorporate a jcarousel slider into a thickbox popup using jQuery, HTML, and CSS?

I'm attempting to incorporate a dynamic car carousel slider into a popup that opens with Thickbox. I've made numerous attempts but haven't achieved success yet. It works when called directly in HTML, but doesn't function properly when ...

Should Angular Flex Layout be considered a top choice for upcoming development projects?

Should I consider using Angular Flex Layout for upcoming projects, even though it is considered deprecated? Despite its deprecation, there are still a high number of weekly downloads on npmjs.com. I am in the process of starting a new Angular project usin ...

Discover the secret to extracting a unique style from inspect mode and incorporating it into your CSS design

I'm currently working on my angular project and I've imported the ngx-editor. My goal is to reduce the height of the editor, but I'm facing some challenges. After inspecting the element, I was able to adjust the height successfully within th ...

How to implement an 8-column layout within a 12-grid bootstrap framework?

Hey guys, so I've been trying to recreate this page with Bootstrap and it's all going smoothly except for this one part. Here is the link I'm referring to: https://i.sstatic.net/0mXMm.png I have 2 questions: Which HTML element should I us ...

Block Button styles not displaying in IE when set to Full Width

I can't figure out why, but it seems to be functioning properly on every other internet platform except this one. The first picture shows the button in IE, the second contains the code, and the third displays the button in Chrome. https://i.sstatic. ...

A horizontal navigation bar featuring a centrally aligned vertical layout and full-height display

I want to align everything on my menu bar vertically in the center, with the a elements taking up 100% of the available height of the menubar (text would be vertically-centered). However, I do not want to fix the height of my menu bar. (If I were to fix th ...

Tips on adjusting section height as window size changes?

Working on a website that is structured into sections. Initially, all links are aligned perfectly upon load. However, resizing the window causes misalignment issues. Check out my progress at: karenrubkiewicz.com/karenportfolio1 Appreciate any help! CSS: ...

Javascript Calculator with Dual Input Fields

I have been given a task to create a calculator by tomorrow using Javascript. Unfortunately, I am currently taking a distance course and Javascript has just been introduced in this assignment. While I am familiar with HTML and CSS, Javascript is something ...

What is the best way to scan through Vue and React component-based web applications?

I am facing an issue when trying to crawl my Single Page Application (SPA) created with the Vue framework, which is similar to React. Despite my efforts, the content does not appear to be rendered during the crawling process. Here is the result I am gettin ...

Delay the jQuery event handler for a few milliseconds before triggering

I'm currently working on a navigation menu, but I've encountered some bugs and I'm struggling to fine-tune it completely. Here are the issues I'm facing, and any help or solutions would be greatly appreciated. The menu items (About ...

The skipping of crucial text in tab focus is adversely affecting the accessibility of the website

My appbar contains an image link, a warning indicating the user's current environment, and details about the logged-in user. While testing accessibility with a screen reader, I noticed that tab focus skips over the user details in favor of a link in ...

vee-validate remains consistent in its language settings

Having trouble changing the error message in vee-validate, any suggestions on how to fix this? import VeeValidate from "vee-validate"; import hebrew from "vee-validate/dist/locale/he"; Vue.use(VeeValidate, { locale: "he", dictionary: { he: { me ...

Vuetify - Implementing a search feature in a table that automatically navigates to the matching row

Currently, I am working with 2 Vuetify data tables that do not have pagination enabled. Each row in the second table corresponds to exactly one parent in the first table. My goal is to be able to click on an entry in the second table and have it automati ...

What is the best way to align the Storefront Menu in the center?

If you want to reproduce the issue I'm facing, visit the demo page of the storefront here: then remove the node <ul id="site-header-cart" class="site-header-cart menu"></ul> that contains the cart box (located next to the menu) so that on ...

The standard color code applied to an HTML button

I need to create an anchor element <a> that resembles an HTML button. However, I am struggling to find the default background color for the input type button. ...