flexbox used to create a fixed sidebar on the left

I want to create a fixed left sidebar using flexbox.

The sidebar should have its own scroll bar if the content is long, and I don't want it to move when I scroll down the main content.

Check out this example for reference: http://codepen.io/tedartus/pen/KmGYNm

However, I encountered an issue where the sidebar also moves when scrolling down.

I came across a thread on fixing the sidebar position with flexbox. I followed the suggestion of making the container as tall as the screen and only adding scrolling to the main content.

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

.content {
  flex: 1 1 auto;
  overflow: auto;
}

While this solution worked, I noticed that the scrollbar on the right disappeared. Any thoughts on why this might be happening?

=> http://codepen.io/tedartus/pen/Pmygpq

I need to address this before tackling the scrollbar for the sidebar.

Thank you

Answer №1

To make adjustments to your .sidebar css, modify the code below:

.sidebar {
    position: absolute;
    width: 220px;
    top: 0;
    bottom: 0;
    overflow: auto;
}
.content {
    overflow: auto;
    padding: 30px;
    background: #eeeeee;
    box-shadow: 0 0 5px black;
    transform: translate3d(0, 0, 0);
    transition: transform .3s;
    height: 100%;

}

You can view the updated code on Codepen: http://codepen.io/bhuwanb9/pen/qmgbNV

Answer №2

To address the issue with the scrollbar, adjusting the content width based on translate values can ensure it remains visible on the screen. Currently, the content is positioned 220px off to the right, causing it to be partially out of view:

.content.isOpen {
  transform: translate3d(220px,0,0);
  max-width:calc(100% - 220px);/* 220px represents the sidebar width/translate value */
}

http://codepen.io/anon/pen/WjPrXv (Feel free to incorporate additional CSS tips from @coderall regarding sidebar overflow)

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

faulty lineup in jquery picture switching feature

I've been working on a website that features a jumbotron with images that transition. I've searched online for solutions, but have come up empty. I know the answer is probably simple, but I just can't seem to figure it out right now. The is ...

How to review the current page in Joomla 2.5

Is there a way to determine the current page the user is visiting in Joomla 2.5? I have a code snippet that checks if the user is on the home page: $menu = $app->getMenu(); if ($menu->getActive() == $menu->getDefault()) { However, I now need a s ...

Encountering an Uncaught TypeError that is hindering an alert for the score, but I am uncertain about the solution despite the game functioning properly

My Yahtzee code is functioning normally during gameplay, but I'm facing issues with getting alerts for the total score and bonus points. I have identified where the problem lies but I am unsure how to resolve it. I attempted debugging through alerts, ...

Is it possible that using foreach($result as $post) in PHP may result in a null return value?

Can someone help me figure out why this code is returning null when trying to fetch data from a MySQL database using foreach($result as $post) and output it in HTML? <?php $db = mysqli_connect('localhost','xxx','xxx',&apo ...

The action of Array.splice unexpectedly changes numerous values, despite being designed to replace just one

My journey to learn coding led me to create my own small idle-clicker-RPG in Javascript and HTML. Currently, I am facing a challenge with my Inventory management codes. Instead of removing and adding items 1:1, it duplicates them when they share the same & ...

Discover a specific segment of the pie chart

Currently, I have a pie chart that has been created using HTML5 canvas. I am able to retrieve the coordinates (X,Y) when the mouse hovers over it. Now, my goal is to determine which slice of the pie chart the Point (X,Y) falls into. Please note: I have ...

Fixing issues with internal web page connections (#x) present in the HTML code (href="#x" id="x")

Can anyone come up with a brilliant solution as to why my internal links are not functioning properly on a webpage? I've coded the HTML with the usual <a href="#link"><button>Some Text</button></a> .... bunch of content .... & ...

"Enhancing iPhone User Experience with CSS Hover Effects

I am experiencing an issue with my website where the hover functionality works perfectly on all devices except for iPhones. On an iPhone, users have to continuously press the screen until the hover transition completes in order to view the information. I ...

How to show a tooltip inline by utilizing CSS styling

Working on a sticky side bar menu with a tooltip feature. While it appears correctly in Chrome and Safari, the tooltip is off-center in IE. This snippet seems to be causing the issue: /* Vertically center tooltip content for left/right tooltips */ .tool ...

Header that stays fixed at the top within a collapsible accordion layout

I'm experimenting with creating an accordion-style layout that transitions to an accordion on smaller screens, as shown by resizing the snippet attached to this question. I'm using flex to establish a sticky header, which is currently only applie ...

Tips for displaying live data in the rows of Element UI's Table

Recently, I've been working with a table that looks like this. <v-table :data="data"> <v-table-column prop="data.attribute" label="Attribute"> </v-table-column> </v-table> Instead of displaying data.attribute in the co ...

CSS: Adjusting alignment differences between local host and server

I've been working on a webpage with rotating background images, and everything looked perfect on my localhost. But once I uploaded it to the server and viewed it in different browsers, some of the people in the images were not positioned as intended, ...

Tabs within the AutoComplete popup in Material-UI

Would it be feasible to showcase the corresponding data in the AutoComplete popover using Tabs? There could be potentially up to three categories of data that match the input value, and my preference would be to present them as tabs. Is there a way to in ...

Font awesome icons 4 and 5 are displaying accurately

When utilizing Font Awesome, I am able to display 4 out of 5 icons correctly. However, the last icon (stackoverflow icon) does not appear: Here is the HTML code: <ul> <li><a href="#"><i class="xcon-facebook"></i></a> ...

Navigating up and down in a horizontal row of 'tabs'

For a school project, I am in the process of creating a website that I wanted to make unique and different. However, I have encountered a major challenge with a tight deadline approaching. Any assistance would be greatly appreciated. Let's address ...

changes in size in relation to the position of the parent element

Utilizing the transition:scale(1.2) property to conceal a div positioned in the lower left corner of the viewport. Currently, the scaling effect originates from the center as intended: View 'CURRENTLY' on Fiddle I aim to scale it as if the div ...

Uniform height across certain thumbnail images

I have hit a roadblock while working on a project, and I am unable to resolve it :) I am using the Bootstrap grid system and I want to display thumbnails within a content section, with six thumbnails per row. The issue is that while the text below each ima ...

Eliminate specified image dimensions when utilizing the "clip:rect" property in CSS and HTML

When trying to resize an image using clip: rect() in HTML, I encountered a problem where the Inspect tool would display the original height and width of the image instead of the resized dimensions. My goal is to achieve the following: On a screen width of ...

What is the best method to deallocate and remove the background-color property of CSS once it has been defined?

There is a perplexing issue that I am unable to resolve. The "Shop" section on this page has an intriguing translucent blue-green background: This background is set using the ID "#left-area". Interestingly, on another page, which can be found at , the sam ...

Preventing a bootstrap data target from opening based on certain conditions

<button type="button" id="submitButton1" name="submitButton1" class="btn btn-primary waves-effect waves-light" ng-click = "validateAndSaveData('upload')" value="Upload Documents" data-target="#myModal1" data-t ...