What is the best way to ensure two tables are aligned side by side in a horizontal

I'm facing an issue with two tables on my HTML page that are aligned horizontally - one on the left and the other on the right. They look good when the browser is maximized but lose their horizontal alignment when the window size is reduced. I have applied CSS to both tables as follows:

Table 1

.viewTable {   
    background-color: #eeeff4 !important;
    border-collapse: collapse;
    border-spacing: 0;
    margin-bottom: 20px;
    width: 79% ;
    margin-left:0;
    float: left;
    clear:both;
}

Table 2

.settleViewTable {
    border-collapse: collapse;
    border-spacing: 0;
    margin-bottom: 20px;
    width: auto;
    margin-right:10px;
    margin-left:10px;
    float: right;
}

I'm looking for a better solution to maintain alignment even when the window size is reduced. Any suggestions?

Answer №1

Table 1 is set to a width of 79%, while Table 2 has both a left and right margin of 10px, totaling 20px. This means the width of Table 2 will be calculated as width:calc(21% - 20px);. This setup ensures that the two tables remain side by side with floating.

To learn more about CSS calc(), visit https://developer.mozilla.org/en-US/docs/Web/CSS/calc

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

Retrieve all colors from the style attribute

I'm on the hunt for a method to extract all CSS colors from a website. Currently, I have been able to manage internal and external stylesheets by utilizing document.styleSheets. However, my issue lies in the fact that any styles directly assigned to a ...

Toggle the jQuery class off when a different element is chosen

I've created a function that toggles a class to change the style of an element when it is selected. However, I'm facing an issue where the new style remains even when another element is selected. Is there a way to make the styling revert back to ...

The React JSX error message "Maximum update depth exceeded" occurs when there

It appears that I am facing an issue of creating an infinite loop while passing props from one class to another. Despite ensuring that the buttons are correctly bound and trigger only once, the problem persists without any solution in sight after thorough ...

Connecting users from a mobile website to a particular item within the Amazon application

Recently, I've been working on linking from my mobile site to a particular item within the Amazon app. My JavaScript code includes a try/catch block that redirects users to the webpage if they don't have the app installed. However, I've foun ...

Issue with Table Element's Full Width Within Parent Element

Here is a demonstration of the scenario in JSFiddle I have made updates to the JSFiddle demonstration here: http://jsfiddle.net/x11joex11/r5spu85z/8/. This version provides more detailed insight into how the sticky footer functions well, albeit with a hei ...

"Troubleshooting a problem with the height of a collapsible div

I am encountering a peculiar problem with the height behavior of a collapsible div. The expanded height of the div persists even after it is closed or collapsed. Please see the image below for reference: https://i.sstatic.net/OetPL.jpg The JavaScript see ...

Prevent unnecessary image resizing during parallax scrolling animation

Check out my demonstration where the image scaling results in the margin-top of the parallax wrapper being unable to dynamically adjust. Demonstration: http://jsfiddle.net/KsdeX/12/ .wrapper-parallax { margin-top: 150px; margin-bottom: 60px; } W ...

A stylish and versatile Bootstrap Modal is the perfect

Just dipping my toes into Bootstrap 4.5, but struggling with the Modal component. I've gone through the documentation multiple times and simply copied and pasted from the website. The code is so basic, yet I can't seem to figure out what's ...

Is there a way to showcase views.py outcomes promptly and dynamically on template.html within a Django project?

I am working on a django website project with a template called exper.html and views.py handling the backend processing. My goal is to allow users to input parameters or text in a textarea, click submit, and have views.py process the input to generate ima ...

Secret button that remains unresponsive upon initial click after materializing

I am facing a problem with my two buttons in the HTML code. One button is supposed to plot data, while the other is meant to download data. The issue arises when the plot button has data and the Excel download button should become visible. Although this fu ...

Styling your content with Bootstrap 4: a sleek col-md-4 design featuring

I have been using this carousel component: https://i.sstatic.net/2haSi.png One issue I have noticed is that there is a border around each block in the carousel. Specifically, on the first slide, the left shadow is not visible, and on the third slide, th ...

What is the updated technique for creating a full-width HTML section in 2023?

In most web designs, the content is typically "contained" to be centered and limited by a maximum width: <!DOCTYPE html> <html> <body> <div id="container" style="width: 1000px; margin: 0 auto;"> ...

Replace Font Awesome icon with a background image

Looking to replace a Font Awesome icon with a background image using only CSS. Current Setup: https://i.sstatic.net/tkPXz.jpg .btn.btn-default.bootstrap-touchspin-up:before { font-family: Fontawesome; content: "\f067"; font-size: 14px; } ...

Tips for utilizing comment tags efficiently

I have encountered an issue with IE7 where my CSS is not functioning properly. In an attempt to target IE7 and lower versions specifically, I inserted IE comment tags into the HTML code. However, despite my efforts, it does not seem to be effective. Initia ...

Basics of CSS border-image explained

Although it seems simple, I'm struggling to figure out what the issue might be. I am attempting to create a div with a specific border on an ASP.Net webpage. CSS: .ResourcesDiv { border-image:url(http://blogrope.com/wp-content/uploads/2013/06/003-w ...

Color highlighting in dropdown HTML items

I'm trying to create a dropdown menu with alternating colors for the items. Can someone please provide the CSS code needed to style dropdown list items using ODD and EVEN? ...

Is Angular causing the issue with Datalist not functioning in IE9?

Autocomplete feature using datalist in Angular works perfectly on all browsers except IE9. I even tried the following workaround: <datalist id="associates"> <!--[if IE 9]><select disabled style="display:none"><![endif]--> <o ...

Is there a CSS Blend Mode alternative for Internet Explorer?

I've implemented the background-blend-mode on this element: <a href="#" class="blend"> <h3>Title</h3> <p>Content goes here</p> </a> It's all set up with a background-image url. When the element with c ...

The internet browser encountered a JavaScript runtime error (0x800a138f) in which it was unable to retrieve property '0' due to it being either undefined or pointing to a

I'm encountering an issue with my javascript/jquery function that retrieves the selected dropdown value. Everything works fine in Chrome, but when I try to run my application in IE, it throws an error. $("#Application_AppCountries").change(function ( ...

Count the amount of exposed items in each row within a specific container size and dimensions

I created a code sample available at demo code to showcase li elements within a ul displayed in a flow-like manner with the use of display:inline. The challenge I am facing is determining the number of complete li items that are not wrapping for each row ...