Adjusting the size of two cards with distinct content simultaneously using Bootstrap

Currently, I am in the process of developing an app using Bootstrap. The main objective of the code snippet below is to establish three rows within a container, with the initial row containing two columns each housing a card. In the first card (top left), my goal is to display two images side by side while maintaining their aspect ratio. On the second column, I aim to include a table. While the current code successfully accomplishes this layout for larger screen sizes, resizing it reveals that the cards do not shrink proportionally, resulting in varying heights. My priority lies in ensuring that the cards scale uniformly, regardless of size changes, so they remain consistent in height. Additionally, I would like the table to implement vertical scrolling once the card's height reaches a specified value. How can I achieve these goals?

table.table>tbody>tr>td {
  padding: 0 !important;
  margin: 0 !important;
  border-collapse: collapse !important;
  border: none !important;
  border-spacing: 0 !important;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5e3c31312a2d2a2c3f2e1e6b706d706e733f322e363f6d">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
  <link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f89a97978c8b8c8a9988b8cdd6cbd6c8d59994889099cb">[email protected]</a>/dist/css/bootstrap.min.css" />
  <title>HTML, CSS and JavaScript demo</title>
</head>

<body>
  <!-- Start your code here -->

  <div class="container-fluid">
    <div class="row row-cols-2">
      <div class="col-7">
        <div class="card">
          <div class="card-body">
            <table id="stream_table" class="table">
              <tbody id="stream_body">
                <tr>
                  <td>
                    <div class="ratio ratio-16x9">

                      <img id="stream_id1" src="https://picsum.photos/seed/picsum/1920/1080" title="" data-bind="attr: { title: tt9 }" style="max-width: 100%; height: auto; position:absolute;visibility: visible;object-fit: fill;" alt="">
                     
                      <img id="stream_idnv1" title="" data-bind="attr: { title: tt10 }" src="../static/img/novideo.png" class="video" style="transform: scale(1.25,1);position: absolute; visibility: hidden; object-fit: fill; top: 0%; width: 100%; height: 100%; opacity: 0.3;"
                        alt="">
                      
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

</html>

Answer №1

When determining the ratio of a box, it is recommended to utilize a fixed height with the vh-100 class name. Additionally, for scrolling when content exceeds the space, you can employ the overflow property in your CSS. The following code snippet has been tested and can be beneficial for you:

table.table>tbody>tr>td {
    padding: 0 !important;
    margin: 0 !important;
    border-collapse: collapse !important;
    border: none !important;
    border-spacing: 0 !important;
}

.card-body {
    overflow: scroll;
}
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="text/javascript"
        src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0f6d60607b7c7b7d7e6755e9152205213e4242507410122a035270243151403355">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
    <link type="text/css" rel="stylesheet"
        href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ae8e5e5fef9fef8ebf1edfee4f2ffafe785feeaefbbfcfaeafecdfdebeeeaf7ebbdabf6faf7f9bcfcef"><strong>Contact Us for Best Information</strong></a>/dist/css/bootstrap.min.css" />
    <title>HTML, CSS and JavaScript demo</title>
</head>

<body>
    <!-- Your original HTML content can go here -->
    <!-- This section can contain different HTML elements and structures based on your requirements -->

</body>

</html>

Answer №2

After some experimentation, I discovered a solution for resizing the page and its components while preserving the aspect ratio. By nesting the table within a cell of another table and enclosing the table-child in a div (), I was able to achieve this effect. Now, when the page is resized, all elements stay in their original positions but just smaller in size.

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

I am having trouble setting the z-index for the navigation component in Tailwind CSS and Next.js

Currently, I am immersed in a Next.js project that utilizes Tailwind.css. Within this project, there is a header component known as nav, styled as follows: <div className="sticky top-0 z-100 body bg-white flex flex-row items-center">Nav con ...

Searching and extracting HTML tags using DomCrawler

Trying to extract text content from HTML tags using the Symfony DomCrawler <html> <strong> This is a bold text </strong> <strong> This is another bold text </strong> <h2> This is header 2 text </h2> </htm ...

What steps can be taken to ensure the visibility and accessibility of two vertically stacked/overlapped Html input elements in HTML?

I have encountered a challenge with my HTML input elements. There are two input elements that overlap each other, and I would like to make both inputs visible while only allowing the top input to be editable. I have tried several approaches involving z-ind ...

Setting an Element's attribute is only visible in the console

Just dipping my toes into the world of Web Development. While playing around with some JavaScript within HTML, I decided to try updating the content of an element. Upon running the code below, "Updated Content" appears in the console as intended. However, ...

Difficulty aligning two images in one div using HTML and CSS

Having trouble with HTML and CSS. I have a div containing 2 images - one for background and the other for an avatar image that I can't seem to center. I've tried using margin:0 auto; and display:block; but it's not working. Current HTML pag ...

Position elements in the center of the page at 33.3333% width

I'm facing a challenge with centering elements that are floated left and have a width of 33.33333% on the page. I want the text inside these elements to remain aligned to the left, but I'm unsure how to go about centering the items: ul.home-pr ...

The unique filter in AngularJS ng-repeat is malfunctioning

I'm attempting to utilize the following distinct filter <ng-repeat="item in allItems | distinct:'itemName'" value="{{item.itemName}}">{{item.itemName}}> However, I'm encountering an error like this, Error: [$injector:unpr ...

Error message indicating that Element <> cannot be scrolled into view persisting despite attempting common troubleshooting methods

Currently, I am utilizing Selenium to create a web scraper for downloading multiple podcast episodes from Spreaker. # https://www.spreaker.com/show/alabamas-morning-news-with-jt for i in range(3): print("Click number: {}".format(str(i))) see_mor ...

Organize icons within a container that spans the entire height

I am looking to organize multiple icons within a container that spans the entire height of the website, rather than just the viewport. Currently, I am only able to achieve the height of the viewport using the following code: .full-container { posit ...

Creating a Texture in html5 and WebGL using an ArrayBuffer

I have an image that I am retrieving on the server side and sending to the web browser through an AJAX call. I need to display this image line by line using WebGL. For example, let's consider an image with dimensions 640X480. This means there are a t ...

What are the steps to customize the appearance of a ComboBox using CSS?

I'm struggling to style the items in a combo box when it's dropped down. Currently using vaadin-time-picker on Svelte, but my issue persists due to the combo box included. Despite experimenting with CSS, I haven't had any success. My goal i ...

Vibrant progress bar design with CSS

Could someone assist me in coding a multicolor progress bar? I would like it to display red when the progress is less than 50, green when the progress is between 50 and 90, and blue when the progress is between 90 and 100. How can I achieve this? ...

Creating a multi-column layout for list items using Bootstrap. Unusual behavior observed (see demo in JSBIN

I am struggling to display items in multiple columns without any strange formatting issues. Can someone help me out? Check out the JSBin for reference: http://jsbin.com/huzurejunu/1/edit?html,css,output https://i.sstatic.net/DxJpW.png <div class="ro ...

How can I implement a search box on my HTML website without relying on Google Custom Search?

Greetings to all! I am currently managing a website filled with HTML content. I am looking to incorporate a search box into the site. After researching on Google, most of the results point towards using Google Custom Search. However, I require a search box ...

Is there a way to ensure that the tab character " " remains consistent in size within a textarea at all times?

My current challenge involves inserting tabs of the same size into a textarea. The example shows that the only variation in each line of the testString is the placement of the \t. However, when displayed in the textarea, the tab sizes differ dependi ...

What is the best approach to define a *.css file in an ASP.NET UserControl?

I am dealing with a CSS file which includes all of the <style> tags used in my website. Is there a way I can connect this CSS file to my UserControl, allowing me to utilize the styles within the CssClass attributes for my child controls? ...

Cause a bootstrap column to have overflowing content rather than expanding

I've searched extensively for the solution to my problem, but haven't found a satisfactory answer yet. My goal is to create a location finder with a map on the right and a list on the left. With over 18,000 locations to search through, the list ...

Assign different colors to headings based on their associated button ids using JQuery

I have a limited number of buttons and headings to work with. Here is the HTML code structure: <button id = "1">1</button> <button id = "2">2</button> <heading id="1">heading1 <button>cli ...

New Feature in Bootstrap 4 Beta: Double dropdown icons now available in Options Menu

I'm facing an issue with the way Bootstrap is displaying my options menu. Here's a screenshot for reference: https://i.sstatic.net/LLxcF.png I'm unsure of what's causing this problem. I've omitted labels in this case, but they do ...

CSS styling not functioning properly

After spending a considerable amount of time on this issue... <div id="pager" style="top: 5px; position: relative; " class="pager" > <form> <img src="http://tablesorter.com/addons/pager/icons/first.png" alt="first" class="first" ...