Tips for adjusting the admin panel's content area to fill the entire width

I am currently working on HTML code for an admin panel. Here is a basic structure:

body {margin: 0}

.adminpanel {
  display: flex;
  height: 100vh;
}

.leftpane {
  width: 250px;
  background-color: #0038a8;
}    

.rightpane {
  width: 87%;
  background-color: #ce1126;
}
<div class="adminpanel">
  <div class="leftpane">
    left
  </div>
  <div class="rightpane">
    right
  </div>
</div>

After setting the .leftpane to 250px, I want the .rightpane to take up the rest of the available width. Currently, I have it set to width: 87%;, which works well on my laptop with a resolution of 1900px.

Do you have any suggestions on how to make this layout work better?

In previous projects, I used CSS frameworks for admin panels, but this time I'm coding from scratch.

Answer №1

To achieve a responsive layout, you can apply the flex-grow:1; property to the right pane and remove the explicit width:

.adminpanel {
  display: flex;
  flex-direction: row;
  height: 100vh;
}

.leftpane {
  width: 250px;
  background-color: #0038a8;
}

.rightpane {
  background-color: #ce1126;
  flex-grow: 1;
}
<div class="adminpanel">
  <div class="leftpane">
    left
  </div>

  <div class="rightpane">
    right
  </div>
</div>

Answer №2

There are two options available for this:

.rightpane { flex-grow: 1; }

Another approach is the traditional way:

.rightpane { width: calc(100% - 250px); }

Answer №3

body {margin: 0}

.adminpanel {
  display: flex;
  height: 100vh;
}

.leftpane {
  width: 250px;
  background-color: #0038a8;
}    

.rightpane {
  flex-grow: 1;
  /*or width: calc(100% - 250px)     */
  background-color: #ce1126;
}
<div class="adminpanel">
  <div class="leftpane">
    left
  </div>
  <div class="rightpane">
    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

Model-view-controller datasets incorporating viewbags

How can I utilize a dataset in a viewbag to showcase the data in a view? I have obtained a dataset from a model and stored it in a viewbag. My intention is to extract the datarows using a foreach loop within the view. Since I already have a variable bein ...

Choose a particular element within an element class using a variable as the selector in jQuery

Is there a way to dynamically add a class to a specific element in an array based on a variable in a for loop, rather than random selection? I need to target elements with the variable provided and possibly apply the class to more than one element if neces ...

Problem encountered when implementing multiple filters in Vanilla JavaScript

I am facing an issue with my HTML page that contains multiple filters using Vanilla JavaScript (no jQuery). The filtering process involves counting matches of filter selections against the data attributes of each element. However, I'm puzzled as to w ...

Slider Troubles - Strange glitch when reaching final slide

Currently, I am in the process of developing a basic slider for a website. Although it is still a work in progress and both the script and styling are unfinished, I have encountered an issue. After clicking on the next button, I am able to cycle through al ...

Seeking a way to display a random div at a 1% rate without generating additional div elements

Searching for an answer to display only one div with a rate of 1/100. Currently, I am utilizing the following JavaScript: var random = Math.floor(Math.random() * $('.item').length); $('.item').hide().eq(random).show(); This method wor ...

Position the checkbox to the left of the label

I currently have a checkbox with ripple effects. The label text is displayed before the checkbox in the code. However, I'd like to change the order so that the checkbox comes before the label text. Occasionally, the entire div expands and contracts. ...

What is the best way to incorporate an onmouseover event so that when the mouse hovers over an image, play/stop/pause buttons are displayed

Furthermore, each button should trigger an event on click. When the pause button is clicked, the button text should toggle between pause and continue, and the action should correspond to the displayed text. This is the HTML code I currently have: Includi ...

Modify inline BODY width using PHP

My PHP script fetches HTML content as a string, and sometimes it includes code with an inline width on the BODY tag. When this width is set to 100%, it disrupts some additional processing that takes place. I'm hesitant to apply an external style sinc ...

What steps should I take to ensure that my table is positioned above my ContentPlaceHolder?

I'm currently working on setting up a menu in the MasterPage that will appear when a hyperlink is clicked. The YardimDokumaniMenuAHREF hyperlink triggers the display of the menu. Upon clicking it, a JavaScript function is invoked. However, I am facing ...

Customizing the default font color in Angular Material

I am currently navigating through theming in Angular Material and feeling a bit disoriented. I have implemented the prebuilt indigo-pink theme by importing it into my styles.scss as shown below: @import "~@angular/material/prebuilt-themes/indigo-pink.css" ...

Use jQuery to switch back and forth between the login and registration forms on a single

I've set up two forms, one for login and one for registration, with the default view showing the login form. There's a link that says "Don't have an account?" and when it's clicked, the registration form will display while the login for ...

Issues arise when trying to manage HTML received as a response from a server in plain text

I have a scenario where I am dynamically generating an HTML table on the server side using Java and then sending it to the client as JSON data. The response looks something like this: <table class="table"></table><thead class="thead-dark"&g ...

What's the best way to ensure that your item list automatically updates the rendered list when an item is deleted

I've developed a web cart using Redux. The cart functions as expected, except for one issue - when I delete an item from the cart, the changes are only displayed after refreshing or navigating to another page. How can I update the view dynamically as ...

Excessive spacing in the <td> elements - TABLE

I am encountering some problems with my table layout. The spacing between the field names and text boxes appears to be too large. Could there be mistakes I'm making that are causing this issue? How can I minimize the gaps? Please refer to the image b ...

Sending unstyled HTML content using JavaMail

Can anyone offer guidance on sending an email using JavaMail with unformatted HTML tags? Here is the code I am currently using: public void sendMail() throws MessagingException, IllegalStateException, IllegalArgumentException { Properties properties ...

What is the method for incorporating jQuery UI effects into buttons that are imported from a basic HTML document?

I am continuously updating the content on my website in three distinct ways: 0) Utilizing jQuery's getJSON('bla.json') to read JSON files; 1) Fetching JSONized C#/Razor classes via jQuery's getJSON('bla.cshtml'); 2) Loading H ...

Tips for centering text in a dijitTextBox:

Ensure that the text is centered vertically with left padding and placeholder text included Check out the image link below: https://i.stack.imgur.com/PbHDa.jpg Snippet of my xPage code: <xe:djTextBox id="djTextBoxSearch" style="width:100%;height: ...

Selecting multiple categories using jQuery

HTML: <ul id="selector"> <li><a href="#" class="group1" rel="group1">group 1</a></li> <li><a href="#" class="group2" rel="group2">group 2</a></li> <li><a href="#" class="group3" re ...

Formatting list items in HTML

I have just finished coding the following HTML code: My main goal is to align the list items - HOME | All About Kittens | Feeding Your Kitten in a proper layout. Currently, they are displayed as a simple list. However, I would like them to be aligned ...

Identify the index of a list item using a custom list created from buttons

When dealing with a dynamically built list like this: <ul id="shortcuts"> <li><input type="checkbox" value="false"/><button>foo</button><button>-</button></li> <li><input type="checkbox" value ...