Place the sidebar component within a container div

I have a component called app-side-menu that I want to place inside a blue rectangle, taking up the full height of the blue div https://i.sstatic.net/OJGVV.png. The issue is that the menu extends beyond the bottom limits of the blue div and moves along with the scroll when I scroll down.

app.component.html

<div class="top-menu" style="border:1px solid red;height: 60px;">  

    <app-top-menu></app-top-menu>

</div>
<div class="wrapper"style="border:5px solid green">

    <div class="left-menu" style="border:3px solid blue">

       <app-side-menu></app-side-menu> 

    </div>

    <div class="main-content">
      <router-outlet></router-outlet>

    </div>
</div>

app.component.css

.top-menu{
    padding: 0%;
    margin: 0px;


}

.main-content{
    float: left;
    border: 1px solid pink;
    height: 100%;
    position: relative;
    width: 86%


}

.wrapper{
    position: absolute;
    width: 100%;
    height:100%
}

.left-menu{
    position: relative;
   float: left;
   width: 14%;
   height: 100%;

}

side-menu.css

[data-component='sidebar'] .first-menu {
  position: fixed;
  background-color: #292a2c;
  height: 100vw;
  width: 75px;
  top: 60px;
  overflow: hidden;
  transition: width 0.5s;
}

Answer №1

If you're looking to achieve a dark menu that spans the full height of the blue box without scrolling with the view-port, positioning the component absolute is the way to go. Using position fixed will ensure it remains in the view-port at all times.

Ensure the parent or .left-menu stays positioned relative and make the following adjustments to your component:

[data-component='sidebar'] .first-menu {
  position: absolute;
  top: 60px; // Adjust as needed
  left: 0;
  height: 100%;
  background-color: #292a2c;
  width: 75px;
  overflow: hidden;
  transition: width 0.5s;
}

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

Trigger a new Action upon successful completion of another action

I am a newcomer to the world of Angular and Redux. I have a common question for which I can't seem to find the right answer or maybe just need a helpful tip. I am utilizing ngrx in my application and I need to update some basic user data and then refr ...

Troubleshooting a Next.js background image problem when hosting on Netlify

I've encountered an issue while attempting to deploy a nextjs website on Netlify. Everything works perfectly on my local server, but once it's on Netlify, the background image URL changes and the image becomes invisible. Original CSS code: backg ...

Defining the dimensions of a Material Dialog box in Angular: A step-by-step guide

Thank you for taking the time to read this. I'm currently trying to create a dialog box with a specific size of 90% in width, but I'm facing some challenges in achieving this. Can anyone guide me in the right direction or just provide me with th ...

Separating content beautifully with a vertical divider in Material UI's Appbar

Trying to incorporate a vertical Divider component within my Appbar in material-ui has proven to be quite challenging. Despite following a solution recommended on Stack Overflow, the issue persists and I am unable to resolve it: Adding vertical divider to ...

How can I handle a queue in Angular and rxjs by removing elements efficiently?

I'm facing a challenging issue with my code that I need help explaining. The problem lies in the fact that a function is frequently called, which returns an observable, but this function takes some time to complete. The function send() is what gets c ...

Do CSS Stylesheets load asynchronously?

Is there a difference in how stylesheets are loaded via the link tag - asynchronously or synchronously? In my design, I have two stylesheets: mura.css and typography.css. They are loaded within the head section of the page, with typography.css being load ...

Unable to Trigger Jquery Scroll Event

I'm trying to figure out why a div is not appearing when the page is scrolled down. The issue is that my page body and most other elements have overflow hidden, except for a table that appears at a certain point on the page when a button is pressed. T ...

Issues with Curved Corner Touchdown Feature

Having trouble with getting the round css to work properly in the below code It seems to be only applying the background color, but not the border styling The border code is on the same line as the round css: style=" border : 1px solid #D6D6D6; and t ...

Struggling to find a solution for directing to the featured homes page without the content overlapping with my navbar and search component. Any assistance would be greatly

Looking for assistance with routing to the featured homes page without the content overlapping my navbar and search component. I simply want it to direct to a new URL without importing the components unless specifically needed. Check out this link I suspe ...

Angular's routing includes a functionality called Conditional Based Auth Guard, which goes beyond simple navigation protection to ensure route protection as

I am currently in the process of developing an Angular 2 application. export const routes: Route[] = [ {path: '',redirectTo: "login",pathMatch: "full" }, {path: 'login', component: LoginComponent }, {path: 'da ...

What is the best way to access a JSON object that has dashes in its key, returned from TranslateService?

Utilizing TranslateService from @ngx-translate/core to retrieve strings in the current language can be done as shown below: this.translate .get(['hotline-card.email-subject', 'hotline-card.email-body']) .subscribe((strings) => { ...

Styling web pages with CSS and utilizing ASP.NET controls

It has come to my attention that when trying to add the 'style' attribute to an asp:TextBox control, or when trying to use a css class to apply a style, it does not seem to work. I find that I have to explicitly set the attribute like this: < ...

Chunk loading in IE 11 has encountered an error

Having an issue with my website which is created using Angular 5. It seems to be malfunctioning in IE 11, and I am encountering the following error in the console: https://i.stack.imgur.com/Ek895.png Any insights on why my Angular code isn't functio ...

Disable, Hide, or Remove Specific Options in a Single Dropdown Selection

A challenge I am facing involves creating a form with multiple select options that need to be ranked by the user from 1-8. However, I am encountering some difficulties in hiding, removing, or disabling certain select options. Below is an excerpt from my f ...

how to manipulate checkbox selection and deselection with reactive forms in Angular 8

Hey there! I'm currently working with an array of objects that contain IDs and values. I'm using reactive forms to bind these objects to HTML, but when I try to select and deselect all, I'm not getting the desired output without any errors. ...

Using Material-UI to showcase a TextField with a labelWidth set to zero

I need to showcase a specific field on my website. https://i.stack.imgur.com/PJUW7.png However, the issue I'm facing is that even when the field is in focus, the border remains unaffected and does not get cut off by the label. https://i.stack.imgur ...

Display a section of the picture at maximum width

Can anyone help with displaying only a portion of an image at full width (100%) without any overflow issues? The code I've tried is not working: .intro_sea { position: absolute; width: 101%; clip-path: inset(30% 50% 0 0); margin: 0; paddi ...

The excessive repetition in Angular flex layout is becoming overwhelming

I discovered and started using the responsive API provided by angular flex layout. While most of the time it works as intended, there are instances where I find myself duplicating directives in the code. Here's a simplified example: <div> &l ...

Retrieve the data from a JSON file using Angular 4

I have a JSON data structure that looks like this: [{"id": "ARMpalmerillas07", "type": "GreenHouse","act_OpenVentanaCen": {"type": "float", "value": 0, "metadata": {"accuracy": {"type": "Float", "value": "07/02/2018 13:08 : 43 "}}}, "act_OpenVentanaLatNS" ...

Utilize the power of Angular 12 and Bootstrap 5 with the ability to load multiple imported scss theme files

I'm currently incorporating Angular 12 and Bootstrap 5 into my project. For loading Bootstrap, I have imported it from my SCSS file along with three theme SCSS files. This is how it appears: style.scss: @import './assets/styles/theme1.scss&apo ...