Center sidenav material 2 in alignment

Using Angular Material 2 presents a challenge for me: While I can align the text in the sidenav to center, I am struggling to align the button correctly. https://i.sstatic.net/vjHw4.png

<md-sidenav-layout fullscreen>
  <md-sidenav #start mode="side">
    <md-sidenav-container align="center">
      <h3>Simple Todos</h3>
      <button md-raised-button (click)="start.close()">Close</button>
      <p>One more text here</p>
    </md-sidenav-container>
    </md-sidenav>
  <md-content>
    <md-toolbar color="primary">

      <button (click)="start.toggle()" md-icon-button [disableRipple]="true"><md-icon>menu</md-icon></button>

      <!-- This fills the remaining space of the current row -->
      <span class="example-fill-remaining-space"></span>
    </md-toolbar>

    <h3>Hello world</h3>

  </md-content>
</md-sidenav-layout>

Answer №1

Creating a header with a large div to contain the menu and applying specific styling.

.menu_container {
  width: 100px;
  height: 60px;
  background: gray;
  position: relative;
}
.menu {
  background: blue;
  height: 40px;
  width: 40px;
  border-radius: 20px;
}
.centered {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
<div class="menu_container">
  <div class="menu centered"></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

Styling <Link> component with styled-components: A step-by-step guide

Utilizing the Link component from @material-ui/core/Link in my TypeScript code was initially successful: <Link href="#" variant="body2"> Forgot? </Link> However, I am exploring the transition to styled-components located in a separate file. ...

Integrate a feature in your form that allows users to preview and edit their submission before finalizing

I've set up my HTML form with the following structure: <div class="container"> <div class="form-group" ng-controller="studentController"> <form role="form" class="well form-horizontal" id="registerForm" name="forms.register ...

The combination of absolute positioning and percentage-based height measurements allows for

For more information, go to http://jsfiddle.net/A2Qnx/1/ <div id='w'> <div id='p'> <div id='c'> </div> </div> </div> With absolute positioning enabled, div P has a height ...

Displaying an array value instead of a new value list in a React component

Situation - Initial number input in text field - 1 List of Items - 1 6 11 Upon removing 1 from the text field, the list becomes - New List Items - NaN NaN NaN Now, if you input 4 in the field. The updated List Items are - NaN NaN 4 9 14 Expected ...

What is the best way to guide a user to a specific page based on the choice they made after submitting a form?

My form includes a list of 6 options where users can only select one. After submitting the form, I want to redirect them to a specific page based on their selection. For example, I have the following 3 options: Facebook Youtube Twitter If a user selects ...

Executing a component method from a service class in Angular

When trying to call a component method from a service class, an error is encountered: 'ERROR TypeError: Cannot read property 'test' of undefined'. Although similar issues have been researched, the explanations mostly focus on component- ...

Using Jquery to select and apply functions to specified div elements

As someone who is relatively new to JQuery, I have a question regarding the .on() function. Take this example: $('div').on('click', function() {$(this).toggleClass('show-description');}); This code selects all the 'div& ...

The functionality to close the Angular Material Dialog is not functioning as expected

For some reason, I am facing an issue with closing a dialog window in Angular Material using mat-dialog-close. I have ensured that my NgModule has BrowserAnimationModule and MatDialogModule included after checking online resources. Your assistance with t ...

Emulate the CSS hover effect with jQuery 코드 희미한

Is there a method in jquery or any other technology that can detect event X and trigger a different event elsewhere? Currently, I am working with an image that has an image map. When a user hovers over a specific area on the map, I would like another part ...

Stop any ongoing search requests in Angular 7 using Ng2SmartTable

My current setup involves Angular version 7.0.1 and ng2-smart-table version 1.4.0. The issue I'm facing is that each search within the table triggers a new API request to fetch data. What I actually want is for only the latest search request to be pro ...

``The issue concerning the preloading layer on the website``

My experience with the website www.wirecreation.net is sometimes marred by an issue during the initial load. It seems that there is a margin of a few pixels on the gray div containing the logo and progress bar at times, but other times it appears with zero ...

Matching Figures to their Descriptions

I am currently working on a website and looking to include images with captions that display the price of each item underneath. The issue I'm facing is that the captions are aligning horizontally instead of vertically. Can anyone provide assistance wi ...

Make the <textarea> occupy the entire available space

How can I make a <textarea> occupy all available space within a <td> element? Upon clicking inside the table cell, the <textarea> should display with precisely the same dimensions as the cell itself, resembling an Excel spreadsheet. I h ...

Is there a method to identify the quantity of audio channels within a <video> element? (HTML5)

I would like to connect an AnalyserNode to each audio channel of a video element in order to perform audio visualization. Currently, my code is functioning properly except for the fact that both AudioContext and MediaElementAudioSourceNode consistently re ...

Enhancing the Appearance of Google Line Charts

Incorporating Google line charts into my upcoming web project has been a goal of mine. I aim to customize them in the style displayed in this image and display dates between months. Can anyone provide guidance on how to achieve this, if it is feasible? ...

steps for embedding a video with a URL

Here's a question for you: Is there an easy way to embed a video using just the URL, without having to deal with complicated 'embed codes' like <iframe src="http://player.vimeo.com/video/41406753?byline=0&amp;portrait=0" width="500" ...

Utilizing JavaScript to trigger the :hover pseudo-class and implement event transfers

Consider this situation: You have a scenario where two images are stacked on top of each other. The image with the highest z-index is transparent and handles click events, similar to Google's Map API, while the image below is for visual representatio ...

Use Javascript to set cookies and remember the show state when clicked

Can you offer some advice? I am looking to add cookies to my simple JavaScript code. Currently, the div is displayed when clicking on a link, but it hides again when the page reloads. I would like to implement cookies to remember the show state for 7 days. ...

How can we use jQuery to animate scrolling down to a specific <div> when clicking on a link in one HTML page and then navigating to another HTML page?

I'm currently working on creating a website for my friend who is a massage therapist. Utilizing a bootstrap dropdown menu, I have added links to different treatments that direct to the treatment.html from the index.html page. Is there a way to creat ...

The JavaScript code that added links to the mobile menu on smaller screens is no longer functioning properly

I recently created a website with a mobile navigation menu that should appear when the browser width is less than 1024px. However, I used some JavaScript (with jQuery) to include links to close the menu, but now the site is not displaying these links and t ...