Adjust the width of the table to scroll horizontally and size down to fit within the

My webpage is structured with a sidebar and content section, using flex display with the sidebar set to 0.15 flex and the content set to 0.85 flex. I want this page to be full width of the viewport.

The issue arises when I try to incorporate a table into the content section. I want the table to fit within its parent div, the content section, and have a horizontal scroll bar if the table exceeds the width of the container.

Currently, the table causes the content section to stretch horizontally, which is not the desired behavior. I want the ability to resize the window, and have the table shrink accordingly.

For an example, please refer to this JSFiddle link: http://jsfiddle.net/kopwmsuq/7/

Here is a snippet of my code:

.page {
  width: 100%;
  height: 100%;
  display: flex;
}

.sidebar {
  flex: 0.15;
  background-color: red;
}

.content {
  flex: 0.85;
  background-color: blue;
  display: flex;
  flex-direction: column;
  text-align: center;
}

.step-content {
  flex: 1;
}

.step-footer {
  display: block;
}

table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

button {
  display: block;
}
  <div class="page">
    <div class="sidebar">
      // sidebar buttons
    </div>
    <div class="content">
      <div class="step-content">
        whatever
        <div>
          <table>
            // BIG TABLE THAT STRETCHS WHOLE PAGE CONTENT
          </table>
        </div>
      </div>
      <div class="step-footer">
      </div>
    </div>
</div>

Answer №1

.container {
    display: flex;
    flex-wrap: nowrap;
}

.container > section {
    width: 100px;
    margin: 10px;
    text-align: center;
    line-height: 75px;
    font-size: 30px;
}

HTML

<div class="container">
    <div class="panel">1</div>
    <div class="box">            
        <table>
            /// table code
        </table>
    </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

Managing the expiration time of a Cookie with ngx-cookie-service: Explained

Currently, I am utilizing ngx-cookie-service in my Angular application. According to the official documentation, it is mentioned that a third parameter can be added for defining the expiration time as shown below: this.cookieService.set('CookieName&ap ...

Use the useEffect hook to pass newly updated data to a FlatList component

I have encountered an issue with updating a FlatList component in my React Native application. The scenario involves running a graphql query to render items and then refetching the data when a mutation is executed using Apollo's refetch option. Althou ...

Distribute the elements evenly between two separate divs

Hello everyone! I have a unique challenge that I hope someone can help me with. I have a list of links to various tests, but different sections require these links to be displayed in different ways. One section needs them spread over two columns, while an ...

Reacting with Node.js: Capturing a selected option from a dropdown menu and storing it in the database

On my React frontend, I have a select dropdown like this: <select name="level" value={level} onChange={this.handleChange} className="form-control"> <option>Begineer</option> <option>Intermediate</option> <option> ...

Effortlessly alternate between dual-column and single-column layouts using CSS

Creating a basic two column layout with fixed widths is my current project. <div id='box'> <div id='ontop'>Ontop</div> <div id='column1'>Column1</div> <div id='column2'&g ...

Adjust the speed of the remaining divs below to move up when one is deleted using Ajax and jQuery

My div elements are arranged from top to bottom, and when one selected div is removed or faded out, all other divs below it shift up suddenly to fill the gap. While this behavior is functional, I would prefer to slow down the movement of the divs shifting ...

Mobile users are unable to access the form

Welcome to my website ! I encounter an issue where I can successfully submit a form on the desktop version, but it seems that the "Next" button below the form is not clickable on mobile. I would greatly appreciate any assistance in resolving this matter. ...

Getting rid of quotes in a JSON result

My unique code snippet Retrieve data = Array[2] : 0:object id : "1" lat : "76.23" long:"21.92" 1:object id:"2" lat:"10.23" long:"12.92" var newCoords=[]; for(_i = 0; _i < ...

Relentless reloading problems with Ajax on Internet Explorer 7

Currently, I am facing an issue with my AJAX implementation along with executing some JavaScript/jQuery code. The problem is specific to IE7 as it keeps reloading the content repeatedly without stopping, while other browsers work fine. I have tried a coup ...

Universal CSS styling for scrollbar design across platforms

I'm feeling extremely frustrated right now because I can't seem to create a basic scroll bar with a specific color and thickness that will display properly on various web browsers and smartphones. Are there any resources available to help me fig ...

Attempting to refresh the choices in a dropdown list by sending a request via jQuery leads to specific

I have a Dropdown on my View that looks like this... <div class="editor-field"> @Html.DropDownListFor(model => model.CategoryId, new SelectList(new List<string>(), ""), "Select ...") </div> Within my controller, there is an action ...

The function causes an unexpected alteration in the coordinates of polygons on a leaflet map

I have been working on enhancing the functionality of a leaflet map by adding triangles with specific rotations to each marker that is created. The code snippet below demonstrates how I achieve this: function add_items_to_map( to_map, longitude, latitude, ...

Troubleshoot PHP Debug and Ajax Notifications in Dropzone

I am currently utilizing the most recent release of Dropzone.js (3.7.1) in combination with a PHP script to handle file uploads to the server. I am interested in receiving a message within the drop zone area in case of an error. When I use the following c ...

Strong tags are not functioning properly within paragraph tags in Firefox

It has come to my attention that when I insert <strong> into a <p>, the text does not appear bold. This issue seems to only occur in Firefox, as Chrome and Safari display it correctly. However, when I place <strong> inside a <li>, e ...

Adding JQuery elements to the map pane

I recently decided to upgrade one of my projects to use the Google Maps API v3 instead of v2. In v2, I used the following code to append a div to the map pane: $("#marker_popup").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE)); Is there a straightforward ...

Getting the iframe onload event in an ASP.NET application

I have integrated ReportViewer to display SSRS reports on my .aspx page. However, since the ReportViewer is rendered as an iframe in the browser, I am looking for a way to trigger a JavaScript function every time the iframe loads. Using window.onload w ...

Focus on a specific button based on its text inside

Two buttons are present with the same class but different content <a class="button ordrViewBtn">Sold Out</a> <a class="button ordrViewBtn">Re-Sell</a> I want to change the color of the "Sold Out" button. Is it p ...

How does the use of <ol> with list-style-type: disc; differ from that of <ul>?

Why create a separate <ul> when visually both unordered lists and ordered lists look the same? <head> <title>Changing Numbering Type in an HTML Unordered List Using CSS</title> <style> ol { list-s ...

What causes the failure of data reaching the server?

I need to make updates to some details in a few tables, but I'm having trouble getting it to work. Can someone help me figure out what's wrong? <body> <form class="" action="view_update_emp.php" method="post& ...

IE11 displaying empty placeholders instead of PrimeNG icons after deployment on server

Currently, I am in the midst of an Angular project that heavily relies on PrimeNg for various components. While everything runs smoothly when testing the project locally across all browsers (including IE11 and Chrome), a hiccup arises once the project is ...