Is there a way to make one column adjust its size automatically, while keeping another column in a fixed position?

The code I created is quite messy.

I need the elements left-sbr and right-sbr to stay fixed in position, while allowing content to resize dynamically based on the browser or window size. Any suggestions on how to achieve this?

.left-sbr{
width:240px;
color:#2d2d2d;
float:left;
border:1px solid #0066FF;
position:fixed;
top:33px;
left:43px;
}
.content{
/*width:500px;*/
margin:33px 1px 0px 287px;
padding:0px 0px 0px 0px;
position:absolute;
width:50%;
/*left:287px;
top:33px;*/
height:100%;
color:#2d2d2d;
float:left;
border:1px solid #0066FF;
}
.right-sbr{
/*margin:33px 0px 0px 0px;
padding:0px 0px 0px 0px;*/
width:23%;
position:absolute;
top:33px;
left:100%;
color:#2d2d2d;
float:right;
border:1px solid #0066FF;
}

This is the HTML Code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />
<title>Learning English Grammar for Non Native Speakers</title>
<link rel="stylesheet" href="in-design.css"/>
</head>
<body>
<div class="left-sbr">
aaaaaaaaaaaaaaa
</div>
<div class="content">Data pada komputer diolah dan simpan dalam bentuk digital atau bilangan biner. Digital hanya mngenal dua nilai saja yaitu : 0 dan 1. Setiap 0 dan 1, disebut dengan istilah bit (binary digit). Bilangan yang terdiri atas delapan nilai (misalnya 10001001) disebut dengan byte (8 bit).<br>
Dalam dunia digital, ada dua jenis basis satuan, definisi basis 2 dan basis 10. Pada basis10, satu kilo berarti 1000 sedangkan pada basis 2 berarti 210 =1024. Berikut tabel basis satuan yang  perlu anda ketahui: Ukuran Definisi basis 2 Defenisi basis 101 kilobytes 1024 byter 1000 bytes1 megabytes 1024 KB=1.048.576 bytes 1000.000 bytes1 gigabytes 1024 MB=1.073.741.824 bytes 1000.000.000 bytes.<br>
</div>
<div class="right-sbr">
cccccccccccccccccc</div>
</body>
</html>

Answer №1

If you're looking for a way to achieve this layout without using jquery, give the following code a try:

<html>
<head>
<style>
* { margin:0; padding:0; }
#content { position:absolute; width:100%; height:100%; color:white; }
.left-sbr { float:left; margin:0px 0px; width:25%; height:100%; background:green; }
.content-center { float:left; margin:0px 0px; width:50%; height:100%; background:grey; }
.right-sbr { float:right; margin:0px 0px; width:25%; height:100%; background:blue; }
</style>
</head>
<body>

<div id="content">
  <div class="left-sbr">left</div>
  <div class="content-center">center or content (as desired)</div>
  <div class="right-sbr">right</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

What methods can be used to accomplish this effect using CSS and/or Javascript?

Is there a way to achieve the desired effect using just a single line of text and CSS, instead of multiple heading tags and a CSS class like shown in the image below? Current Code : <h2 class="heading">Hi guys, How can i achieve this effect using j ...

Preventing automatic image adjustment in CSS during zooming in or out

<div class="footer"> <img class="fisk" src="fisk1.jpg" alt="fisk"> </div> I am facing an issue with keeping the size of an image constant when zooming in and out. Despite trying various methods, I have not been successful in achieving ...

What is the proper syntax for creating a layout with DIV and CSS?

Is there a way to create a master page for asp.net that includes 3 sections using div elements? I want to split the window into a left pane for tree view navigation, a top banner type div, and a main content window under it where child pages will be loaded ...

Create a div element that initially aligns to the left, expands to the full width of the window, and then shrinks back

Hi there! I am currently diving into the world of javascript and jQuery, with a specific goal in mind. I want to create functionality where a div expands to the width of the window when clicked, then shrinks back down to its original size but switches alig ...

What is the best way to retrieve an item if it is a sibling of a specific tag?

My HTML document is quite lengthy, but here's a snippet: <tr> <td data-bind="text:name, css: isActive() ? 'variable-active': 'variable-inactive'" class="variable-active">Vehicle</td> &l ...

How can I use Bootstrap and jQuery to automatically resize the container class to a smaller size when the sidebar is activated?

After enhancing this question and adding more code to my example, I decided to repost it in a better form. However, despite wanting to delete this one, the instructions advise against it. If you're interested, feel free to check out my revised questi ...

Tips for inserting manual line breaks in justified text

My task involves taking a 5-page story from a Word document and implementing it on a website. #reading { hyphens: auto; text-align: justify } <div style="font-size: 20px; width: 750px; margin-bottom: 4em;" class="reading" id="reading"> TextT ...

Storing the slider value in a universal variable and displaying it in a div

I am currently working on a jQuery slider feature for my project. My goal is to extract the value from the slider, display it in a div element, and store it as a global JavaScript variable. It needs to perform these actions immediately as the slider is bei ...

Bug in floating elements within a header causing issues with IE6 and IE7

We are currently facing an issue where an anchor tag is floating right inside a header. While it displays correctly on IE8 and Firefox, we are encountering problems with it popping outside the header box. Does anyone have any suggestions on how to prevent ...

javascript snippet for extracting the dynamically created div IDs

Currently, I am developing an application using Java and AngularJS. Within this project, there is an HTML page that iterates through an object to display the values on the page. Here is the snippet of the HTML code: <div id="{{value.pageIndex}}" ng-re ...

Display the iframe once the user clicks on the modal

I am encountering a slow loading issue on a page of my website that contains 60 iframe elements within w3-modals divs. These iframes all load as soon as the page loads, causing significant delays in loading time. Is there a way to optimize the loading of t ...

Selecting options using AngularJS to parse through a list

I am faced with a challenge involving a collection of strings representing years. Here is an example: $scope.years = ["2001", "2002", "2003", ...]; My goal is to display these values in a select tag within a web page. However, whenever I attempt this usi ...

Identifying activity on a handheld device

I am currently working on a website and I have noticed that it doesn't work as well on mobile devices as it does on desktop. There are performance issues that need to be addressed. I've seen other websites redirecting users to a different page wh ...

What is the best way to place an <a> tag and a <p> tag side by side in an HTML

I have a question on organizing this HTML code: <ol class="results-list"> <% @results.sort_by { rand }.each do |result| %> <li class="<%= 'checked-out' if result.catalog_item.library_status == 'Checked out&apos ...

Issues with Flexbox functionality on Internet Explorer 11

My code is working perfectly in Firefox, Chrome, and Edge, but unfortunately not functioning properly in IE11 due to issues with the flex model. Can someone help me troubleshoot this? Here's how it appears in Firefox: https://i.sstatic.net/BJgVt.png ...

Struggling with implementing CSS in React even after elevating specificity levels

I am struggling with a piece of code in my component that goes like this: return ( <div className="Home" id="Home"> <Customnav color="" height="80px" padding="5vh"/> <div className= ...

Arranging Radio Buttons in a Row and Aligning a Radio Input Group Side by Side using Bootstrap 5

"I'm having a little issue with aligning radio buttons and a radio input group inline on the same line. The input group keeps moving to a new line for some reason. Can anyone help?" Below is the code snippet: <div class="d-flex flex ...

The issue with the $(window).width() property not functioning correctly in Internet Explorer

Currently, I have a Div element with absolute positioning: <div id="target" style="height: 300px; position: absolute; top: 275px;"></div> My goal is to calculate the horizontal resolution of the screen using JavaScript. With this width, I the ...

The function .innerHTML is not functioning correctly, at least in my opinion

When I utilize .innerHTML to insert text into a textarea, the script stops functioning if I manually begin editing the text in the textarea. Here is the code snippet: (function($){ addPort = function(name) { switch(name) { case 'name1': ...

Executing a function when a tag is deleted using ngInputTags in AngularJS

Is there a way to trigger a function when removing a tag? I've attempted different approaches without success. Any suggestions on how to achieve this? <tags-input ng-model="vm.studentObj.assigned_employees" display-property="name" > </tags-i ...