Creating a three-column layout in HTML5 with resizable left and center columns, and a fixed right column

Looking to create a full screen layout with three columns, where the left/center column is resizable and the right column remains fixed.

Currently using the resize style for the left area, but running into issues as the center area does not adjust in size properly. I'm open to using flex if that's a better approach. It needs to be compatible with HTML5 for web-sockets without relying on JavaScript for styling.

Thank you! :-)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="Content-Security-Policy"  content="connect-src * 'unsafe-inline';">
        <style>
            body    {
                    margin:0;
                    padding:0;
                    }

            #container      {
                                overflow: none;
                                height: 100vh;
                                width: 100vw;
                                margin: 0;
                                padding: 0;
                            }

            #a_left         {
                                float:left;
                                height: 100vh;
                                width: 75%;
                                background-color: black;
                                overflow:auto;
                                resize: horizontal;
                            }
            #a_center       {
                                float:left;
                                height: 100vh;
                                min-width: 80px;
                                width:10%;
                                overflow: none;
                                background-color:darkgray;
                            }
            #a_right        {
                                float:right;
                                height: 100vh;
                                width: 40px;
                                min-width: 40px;
                                max-width: 40px;
                                overflow:none;
                                background-color:darkslategray;
                                color:white;
                            }

            #al_text        {
                                width: 100%;
                                height: 95%;
                                overflow-y: auto;
                                background-color: black;
                                color:white;
                            }
            #al_cmd         {
                                width: 100%;
                                height: 5%;
                                overflow: none;
                                background-color: darkslategray;
                            }
            #ac_map         {   width:100%;
                                height: 25%;
                                overflow: hidden;
                                background-color: #222222;
                                color: white;
                            }
            #ac_paged       {   width:100%;
                                height: 75%;
                                overflow-y: auto;
                                background-color: #222222;
                                color: white;
                            }


    </style>
    </head>
    <body>
        <div class="container">
        <div id="a_left">
            <div id="al_text" role="log" aria-live="polite">
                A lot of text goes here.
            </div>
            <div id="al_cmd">
                <table width="100%">
                    <tr>
                        <td style="width:10%; color:white;">Command</td>
                        <td style="width:70%;"><input style="width:97%;" type="text" id="message"/></td>
                        <td style="width:15%;"><input id="btnSend" type="button" value="Send" disabled="disabled" onclick="onSendClick()"></td>
                    </tr>
                </table>                            
            </div>
        </div> <!-- /a_left -->
        <div id="a_center">
            <div id="ac_map">
                An image goes here.
            </div>
            <div id="ac_paged" aria-live="polite">
                Text that sticks goes here and it could be very long. 
            </div>
        </div> <!-- /a_right -->
        <div id="a_right">
            In<br/>
            Eq<br/>
            He<br/>
        </div>        
        </div> <!-- /container -->

        </body>
</html>

EDIT1:

After implementing Antonio's solution, I found better results by starting with a large left column DIV and a fixed right column DIV. Then placing the left and center columns inside the left column, making them resizable. This approach improves the user experience while resizing.

Answer №1

To achieve the desired layout, utilize the 'display: flex' property in your CSS.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="Content-Security-Policy"  content="connect-src * 'unsafe-inline';">
        <style>

body    {
          margin:0;
          padding:0;
          }

  #container      {
                      /*! overflow: none; */
                      height: 100vh;
                      width: 100vw;
                      margin: 0;
                      padding: 0;
                      display: flex;
                  }

  #a_left         {
                      /*! float:left; */
                      height: 100vh;
                      width: 75%; /* <--- Initial Width */
                      background-color: black;
                      overflow:auto;
                      resize: horizontal;
                  }
  #a_center       {
                      /*! float:left; */
                      height: 100vh;
                      min-width: 80px;
                      /*! width:10%; */
                      /*! overflow: none; */
                      background-color:darkgray;
                      flex: auto;
                  }
  #a_right        {
                      /*! float:right; */
                      height: 100vh;
                      width: 40px;
                      /*! min-width: 40px; */
                      /*! max-width: 40px; */
                      overflow:none;
                      background-color:darkslategray;
                      color:white;
                  }

  #al_text        {
                      width: 100%;
                      height: 95%;
                      overflow-y: auto;
                      background-color: black;
                      color:white;
                  }
  #al_cmd         {
                      width: 100%;
                      height: 5%;
                      overflow: none;
                      background-color: darkslategray;
                  }
  #ac_map         {   width:100%;
                      height: 25%;
                      overflow: hidden;
                      background-color: #222222;
                      color: white;
                  }
  #ac_paged       {   width:100%;
                      height: 75%;
                      overflow-y: auto;
                      background-color: #222222;
                      color: white;
                  }



    </style>
    </head>
    <body>
        <div id="container">
        <div id="a_left">
            <div id="al_text" role="log" aria-live="polite">
                A lot of text goes here.
            </div>
            <div id="al_cmd">
                <table width="100%">
                    <tr>
                        <td style="width:10%; color:white;">Command</td>
                        <td style="width:70%;"><input style="width:97%;" type="text" id="message"/></td>
                        <td style="width:15%;"><input id="btnSend" type="button" value="Send" disabled="disabled" onclick="onSendClick()"></td>
                    </tr>
                </table>
            </div>
        </div> <!-- /a_left -->
        <div id="a_center">
            <div id="ac_map">
                An image goes here.
            </div>
            <div id="ac_paged" aria-live="polite">
                Text that sticks goes here and it could be very long.
            </div>
        </div> <!-- /a_right -->
        <div id="a_right">
            In<br/>
            Eq<br/>
            He<br/>
        </div>
        </div> <!-- /container -->

        </body>
</html>

Answer №2

Is this functioning correctly?

<!DOCTYPE html>
<html>
   <head>
      <meta charset="UTF-8">
      <meta http-equiv="Content-Security-Policy"  content="connect-src * 'unsafe-inline';">
      <style>
         body    {
         margin:0;
         padding:0;
         }
         #al_text        {
         width: 100%;
         height: 95%;
         overflow-y: auto;
         background-color: black;
         color:white;
         }
         #al_cmd         {
         width: 100%;
         height: 5%;
         overflow: none;
         background-color: darkslategray;
         }
         #ac_map         {   width:100%;
         height: 25%;
         overflow: hidden;
         background-color: #222222;
         color: white;
         }
         #ac_paged       {   width:100%;
         height: 75%;
         overflow-y: auto;
         background-color: #222222;
         color: white;
         }
         .container {
         display: flex;
         flex-flow: row nowrap;
         width: 100%;
         div{
         height: 100vh;
         }
         }
         #a_left {
         overflow: auto;
         resize: horizontal;
         height: 100vh;
         max-width: 75%;
         width: 100%;
         }
         #a_center {
         min-width: 80px;
         width: 100%;
         overflow: none;
         }
         #a_right {
         max-width: 40px;
         width: 100%;
         }
      </style>
   </head>
   <body>
      <div class="container">
         <div id="a_left">
            <div id="al_text" role="log" aria-live="polite">
               A significant amount of text is placed here.
            </div>
            <div id="al_cmd">
               <table width="100%">
                  <tr>
                     <td style="width:10%; color:white;">Command</td>
                     <td style="width:70%;"><input style="width:97%;" type="text" id="message"/></td>
                     <td style="width:15%;"><input id="btnSend" type="button" value="Send" disabled="disabled" onclick="onSendClick()"></td>
                  </tr>
               </table>
            </div>
         </div>
         <!-- /a_left -->
         <div id="a_center">
            <div id="ac_map">
               An image will be displayed here.
            </div>
            <div id="ac_paged" aria-live="polite">
               Lengthy text is inserted here and it may extend indefinitely. 
            </div>
         </div>
         <!-- /a_right -->
         <div id="a_right">
            In<br/>
            Eq<br/>
            He<br/>
         </div>
      </div>
      <!-- /container -->
   </body>
</html>

The #a_left has a maximum width set to 75%, while the #a_center should have a minimum width of 80px, with the #a_right occupying a maximum width of 40px.

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

Ways to extend the default hover duration for the <a> title attribute (tooltip)

Is there a method to extend the length of time that a tool tip appears when using the title attribute in an HTML tag? In Internet Explorer, it seems to vanish after only around 5 seconds. Is there a way to make it last longer? ...

Setting the z-index to place an absolutely positioned element below a relatively positioned one

I am currently facing a challenge where I need to position an element under another one that has already been relatively positioned. The blue box must remain relatively positioned due to specific constraints within the website development process. For bet ...

Activate the button when the password is correct

Check out my code snippet: $("#reg_confirm_pass").blur(function(){ var user_pass= $("#reg_pass").val(); var user_pass2=$("#reg_confirm_pass").val(); var enter = $("#enter").val(); if(user_pass.length == 0){ alert("please fill password ...

Ways to conceal a label and the input field when a radio input is switched on

In my HTML file, I have coded an application form using CSS to style it. Some of the tags have been removed for display purposes. <label>Member</label> <input type="radio" name="Answer" value="Yes"/>Yes<br/> <input type="radio" ...

"Troubleshooting the non-functional :before pseudo-element in a Select-Box

I am having trouble with my CSS. Below is the code I am using: /*Custom Select Box*/ select#user_select { background-color: var(--white); float: right; color: var(--dark_grey); width: 30%; height: 3rem; padding-left: 3%; bord ...

Enhance each category changing with jQuery page transitions

Is there a way to add page transitions based on category names and quantities in PHP? For example, when clicking on the "office" category, can a popup overlay be displayed with the category name and quantity while the content loads? The focus is on creat ...

Toggle the visibility of 2 Form Fields by checking the Checkbox

Hi, I am trying to display two form fields when a checkbox is selected. These fields are required, so they should only be displayed when the checkbox is checked and should be mandatory. However, I am facing issues with hiding the fields when the checkbox i ...

Is it possible to navigate to a different section of a webpage while also jumping to a specific id within that section seamlessly?

I'm trying to create a navbar link that will take me directly to a specific section of a page, but I'm having trouble getting it to work. Here's what I've tried: <a href="home#id" class="nav-link text on-hover"></a> Where ...

Modify the alignment and orientation of the data within RadHtmlChart

I have a chart: <telerik:RadHtmlChart ID="chrtInvestmentAmount" runat="server" Transitions="true" DataSourceID="SqlDataSource1" Height="256px" Skin="Glow" Width="1024px" RenderMode="Auto"> <PlotArea> <Series> ...

Retrieve the value from an input field when the value is returned from JavaScript

Scenario: I'm currently working on creating a QR reader to retrieve a specific value. You can check out the progress here: What's functioning: scanning. When I scan a QR code, a value is displayed in the text box. Here's the code snippet b ...

The mobile responsive view in Chrome DevTools is displaying incorrect dimensions

Seeking some clarification on an issue I encountered: I recently created a simple webpage and attempted to make an element full width using width: 100vw. However, I observed that on screens smaller than around 300px, the element appeared smaller and not t ...

The anchor tag <a> is configured for inline display but is unexpectedly occupying the entire space

I am currently incorporating Bootstrap into my HTML, however, the <a> tag is behaving like a block display despite the fact that I have specified the CSS to be display:inline; <!doctype html> <html> <head> <link rel="styleshee ...

Tips for eliminating the pesky "ghost" line that appears in your coded HTML email

Check out this Sample Code: <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"> <head> <title></title> & ...

Determining whether an element possesses an attribute labeled "name" that commences with a specific term, apart from the attribute "value"

I'm planning to use distinctive data attributes with a prefix like "data-mo-". Let's say I have the following elements: <span data-mo-top-fade-duration="600">Title 1</span> <span data-mo-bottom-fade-duration="600">Title 2</ ...

Utilize jQuery to dynamically load and assign unique ids to elements within an array

I am seeking assistance with dynamically assigning unique IDs to elements in an array using JavaScript and jQuery. I am new to these languages and need some guidance. function assignIds() { var elementIds = ['name', 'lname', ' ...

Strange circle border appearance in Android / Chrome device

Having an issue with my code on a Samsung Galaxy S5 in Chrome 54.0.2840.85, Android 6.01. You can view the problematic codepen here: http://codepen.io/johnsonjpj/pen/jVpreB The border displays correctly on Firefox and iPhones, but not on my device. Trou ...

The Radio button and Checkbox values are causing an issue where the Radio button is continuously summing upon clicking without a limit. Why is this happening? Check out

I'm currently stuck in a function and believe it would be helpful for you to guide me along the correct path. My goal is to sum the values of checked boxes with the values of checked radio buttons. However, the radio values are continuously accumulat ...

JavaScript function failing to validate password

While engaging in an online game where the objective is to uncover a password by inspecting the page source or element, I encountered a puzzling line: if(el.value == ""+CodeCode+""). My assumption is that el.value represents my guess, and it indicates that ...

AngularJS filter that retrieves only values that have an exact match

In my AngularJS application, I have a checkbox that acts as a filter: Here is the data being used: app.controller('listdata', function($scope, $http) { $scope.users = [{ "name": "pravin", "queue": [{ "number": "456", "st ...

Highlighting the current menu item by comparing the URL and ID

Looking to make my navigation menu items active based on URL and ID, rather than href. None of the suggested solutions (like this one, this one, or this one) have worked for me. This is how my Navigation is designed: <nav id="PageNavigation"& ...