Maintain the center 1024px width while expanding the side columns to fit the entire page?

Is there a way to make the side divs extend to cover the entire page width?

http://jsfiddle.net/p94vxnp2/1/

        <style>
            #page_body_table {
                display: table;
                width: 100%;
                vertical-align: center;
            }

            #page_body_left {
                display: table-cell;
                max-width: 100%;
                border: 1px solid black;
            } 

            #page_body_middle {
                display: table-cell;
                max-width: 1024px;
                border: 1px solid black;
            }

            #page_body_right {
                display: table-cell;
                max-width: 100%;
                border: 1px solid black;
            }

            @media screen and (max-width: 675px) {
                #page_body_left, #page_body_right {
                    display: none;
                }
            }
        </style>
        <center>
            <div id="page_body_left">
                left
            </div>
            <div id="page_body_middle">
                this is content of page
            </div>
            <div id="page_body_right">
                right
            </div>
        </center>

Answer №1

To ensure that display:table-cell functions properly, it is important to apply display:table to the parent element.

In this particular scenario, make sure to include display:table in the #page_body section.

Answer №2

To achieve a responsive layout, remove the use of max-width. Define the middle div with a fixed width of 1024px, while keeping the side divs widthless. By setting the wrapper div to width: 100%;, all elements will adjust automatically.

http://jsfiddle.net/qr8xvjp5/9/

Answer №3

To horizontally align a div, you can use the following method:

.horizontal-center {
    Margin: 0 auto;
    Width: 800px; // Adjust as needed
}

No need to add margins on the sides.

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

Facing a node.js installation issue on Windows 10 while using Visual Studio Code (VS

Issue encountered while trying to execute "DownloadString" with one argument: Unable to establish a secure connection due to SSL/TLS channel creation failure. At line:1 char:1 + iex ((New-Object System.Net.WebClient).DownloadString('https ...

Media query causing CSS display:none to malfunction

I'm currently working on making my website responsive, and I have a specific requirement where I need to hide an anchor when the screen size is under 850px. The code snippet I have is as follows: My goal is to display the first anchor (#tryitnow) by ...

The code is not executing properly in the javascript function

Hello there! I've created a basic login form with JavaScript validation, but for some reason, the code below isn't functioning properly. Here is my HTML and JS code: <head> <script type="text/javascript"> function ha ...

How can I activate the mobile zoom feature on kinetic js?

I am currently working on a website using kinetic js + html5 canvas. Everything looks great on the web, but I am facing some issues with the display on mobile devices. Is there a solution to enable the mobile pan and zoom function in kinetic js? Thank you ...

Utilizing PHP for Substituting URLs within HTML

Is there a way to use PHP to eliminate an entire <iframe> tag that contains the link abc.com? If I searched the following code for abc.com: ‹iframe src="http://abc.com/abcd.html"›‹/iframe› ‹iframe src="http://abc.com/lmno.html"›‹/ifr ...

What could be the reason my Bootstrap webpage is not optimized for mobile devices?

My website is currently hosted at "nateshmbhat.github.io". I have implemented mdboostrp's row and col for the structure of my website, but unfortunately, it is not very mobile-friendly as it displays a lot of unnecessary background space. If you woul ...

Creating an HTML form that dynamically populates a second select dropdown from a MySQL database, depending on the value selected

How can I dynamically populate the second select input in my HTML Form based on the value selected in the first select input? <form action="hidden/add_training.php"> <select name="race_type" id="race_ ...

Setting the innerHTML of the document body to "<P><HR>" can result in failure on Internet Explorer

Our software utilizes an embedded IE control, and we have encountered an issue where setting: document.body.innerHTML to <P><HR> triggers an OLE exception with the message "Unknown runtime error". This behavior was replicated in the IE brows ...

Press the button using the spacebar

I am facing an issue where I have a button with an anchor element that I need to trigger with the spacebar key for accessibility purposes. However, instead of triggering the button, pressing the spacebar causes the page to jump down when the button is in f ...

Manage numerous canvas animations

Is there a way to interact with an already drawn Canvas animation? I am attempting to create 3 distinct tracks that can be controlled by a "Start" and "Stop" button. However, when I click the Start button on the first canvas, it triggers the last canvas in ...

Unable to access Bootstrap dropdown menu after initial ajax form submission

I am encountering an issue with a dropdown menu on my webpage, specifically within the manager.php file. Please excuse any formatting discrepancies as I am using Bootstrap: <!-- Bootstrap --> <script type="text/javascript" src="https://netdna ...

I encountered an error message that said: "Cannot assign '12': 'Cart.product' must be a 'Product' instance. Can someone please assist me in resolving this problem?"

[Included in the image of my code is the add-to-cart function where the error can be found on line 5] def add_to_cart(request): user = request.user product_id = request.GET.get('prod_id') product = Product.objects.get(id=product_id) ...

How can I eliminate unnecessary gaps in a CSS slider design?

Currently, I am in the process of learning CSS3 and attempting to create a purely CSS slider. Everything has been going smoothly until I encountered an unexpected padding or margin within my slider. After making some adjustments to the margins, the issue ...

Select the input element in CSS that does not have a parent with the class name 'classname'

In my stylesheet, I have a specific rule that styles various input fields and select elements. However, I'm facing an issue where this styling is being applied to all text fields on the page, including ones inside certain elements with a specific clas ...

Slider and overflow problem detected

I am currently attempting to make Unslider functional, but at present, it appears as though there is simply a stack of images on top of each other. Below is the HTML code being utilized: <div id="main"> <div class="slider"> <ul> ...

Struggling to align a search box with other items in a custom navbar using Bootstrap 4?

I created a unique navigation bar using Bootstrap 4's grid system. The navbar is designed with two sections: one for the navigation items on the left and another for the search box on the right. Unfortunately, I am facing an issue where the search box ...

Trouble with Pre-populating Form Select Elements in React - Auto-populate Feature Failing to Work

With my working React ReduxForm component, I'm struggling to pre-populate a Select input in the form while still allowing it to be changeable. Despite searching through documentation and forum posts, I haven't found a solution yet. It seems like ...

How can I efficiently make a dropdown menu with search functionality instead of using datalist?

I am currently working on creating a custom searchable input field that makes backend calls. Instead of using datalist, I want to design a unique UI with ul and li items. While I have successfully implemented the search functionality, I am facing a glitc ...

a single button with dual functionalities

I am new to the development field and have a question about jQuery. I want a single button to perform two different actions. For example, let's say we have a button labeled Pause/Resume. When I click on the button, it should first display "Pause", and ...

Steps for customizing a button's look

After installing the MemberPress plugin, I noticed that when I add my custom class, the "Login" button does not change. How can I rectify this issue and ensure that everything functions correctly? Original code <div class="submit"> <input t ...