Utilizing Angular Material for Styling the Web

https://i.sstatic.net/GVcgu.png I am new to working with Angular and currently, I have a sidenav container with the content being a mat toolbar. My issue is that when viewed on a full-sized desktop, the background color of the toolbar stretches and fills the entire width, but on a phone, there is a gap left which doesn't look good.

I tried setting the mat sidenav content width to 100% hoping it would fill the entire space.

https://i.sstatic.net/tK6aH.png

Here is the HTML code for reference:

<mat-sidenav-container class="sidenav-container">
    <mat-sidenav #drawer
                 class="sidenav"
                 fixedInViewport
                 [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
                 [mode]="(isHandset$ | async) ? 'over' : 'side'"
                 [opened]="false">
        <mat-toolbar>
            <button mat-button
                    (click)="drawer.close()">
                <mat-icon>close</mat-icon>
            </button>
        </mat-toolbar>
        <mat-nav-list>
            <a mat-list-item
               routerLink="/"
               (click)="drawer.close()">Home</a>
            <a mat-list-item
               routerLink="/products"
               (click)="drawer.close()">Products</a>
        </mat-nav-list>
    </mat-sidenav>
    <mat-sidenav-content>
       // Toolbar and other content here...
    </mat-sidenav-content>
</mat-sidenav-container>

And here is the CSS styling:

.logo {
    display: flex;
    margin: auto auto;
    outline: none;
    align-self: center;
    justify-content: center;
    align-self: center;
    min-width: 100px;
    max-width: 100px;

    .ww-logo {
        width: 60%;
        cursor: pointer;
    }
}

.button {
    border: 1px solid red;
    width: 10px;
}

.sidenav-container {
    height: 100%;
    width: 100%;
}

mat-sidenav-content {
    width: 100%;
}

Any help or suggestions would be greatly appreciated. Thank you!

Answer №1

It seems like you're encountering an issue where your mat-toolbar elements are overflowing their allotted horizontal space. One possible solution could be adjusting the sizing of your logo to free up some space.

Additionally, I noticed that in your .button class, you've set the width: 10px; property, but it doesn't seem to be taking effect. This could be because the default style for mat-button includes a min-width: 64px; rule that may need to be overridden if you want your buttons to be smaller.

If adjusting the widths resolves the issue, you might also consider tweaking the padding on your buttons. The snippet below is a suggestion, though I haven't had a chance to test it:

.button {
    border: 1px solid blue;
    min-width: 32px !important;
    padding: 2px !important;
}

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

Issues with escaping HTML encoding

Currently working on an Android app that involves querying a webservice and receiving a JsonObject. Once I have the desired String, I encounter characters like: est&amp;aacute; I've experimented with two methods: StringEscapeUtils.escapeHTML4(te ...

Is JavaScript not having an impact on your HTML code?

I am attempting to create a dynamic number change when the user interacts with the "range-slider" element, but the number is not updating as expected. Below is the code I have written: var rangeSlider = function() { var slider = $(".range-slider"), ...

Utilizing activatedRoute in Angular to retrieve encoded query parameters

I am facing an issue with my Angular application, where it is loaded after being redirected from another application. I need to access query parameters when the authentication website returns to my Angular application. The URL appears as: http://localhost ...

Is it possible to load a webpage in a WebBrowser control without displaying certain HTML elements by their IDs

Is there a way to load a specific page using the WebBrowser control without displaying unwanted advertisement banners in the 'tb' DIV element? I've searched online and came across an example that uses the mshtml reference, but I can't ...

Which material design framework would be more suitable for my Angular 6 application - Angular Material or Bootstrap Material?

When starting my new Angular 6 application with Material Design, the big question arose: which material library should I use? Angular Material (https://material.angular.io/) Material Design for Bootstrap () Another option is the Bootstrap Material libr ...

Using Angular's ng-if directive to close an HTML tag

I have a complex table structure with a td element that I need to conditionally close before or after certain events. Using the NG-IF directive is presenting challenges as it interferes with closing the TD tag within the NG-CONTAINER. Is there a way around ...

Adjust the setting for the useHash parameter within the RouterModule during execution

I am faced with a situation where I need to dynamically load my router module option useHash in my Angular application, sometimes with true and other times with false. This decision depends on the server state data that is available in the global window ob ...

What is the reason for index always being not equal to 0?

<script> var index = 0; $.getJSON("./data/data.json", function(json) { $.each(json, function(data) { var html = ""; if(index == 0) { console.log(index + " fir ...

The headline is being improperly rendered inside a black box on Firefox

A while back, I inquired about creating a black box with padding around a two-line headline. The solution worked well, except for older versions of Internet Explorer. However, in Firefox, there are occasional issues with the display looking jagged. This oc ...

Errors with pointer events occurring within nested iframes on Chromium 78

At first glance, it seems like a bug specific to Chromium. I have already reported this issue in a bug report. Since progress is slow on that front, I am posting a question here primarily to see if anyone else has encountered similar or related issues and ...

Is the issue of Padding Overlap with Sidebar Item List getting in the way?

I am currently new to coding in HTML and CSS, so please bear with me if my code seems outdated or unconventional. I am working on creating a basic test website with a sidebar, but I'm encountering an issue where the items in my list are overlapping du ...

I am unsure of the best method to position this using flex in Bootstrap 5

Introduction to Bootstrap 5 Challenge: Greetings! I am currently exploring Bootstrap 5 after a hiatus of two years, and I have encountered a problem. Despite reviewing the documentation on the official Bootstrap 5 website, I am unable to position the new c ...

Angular - delay execution until the variable has a value

When the ngOnInit() function is called, the first line of code retrieves a value from local storage which is then used to filter data from the database. Both actions happen simultaneously, resulting in an issue where I don't receive the expected resu ...

Exploring the intricacies of using jquery text() with HTML Entities

I am having difficulty grasping the intricacies of the jquery text() function when used with HTML Entities. It appears that the text() function converts special HTML Entities back to regular characters. I am particularly uncertain about the behavior of thi ...

Ways to retrieve the initial value and proceed with a subsequent subscription method

I have created a basic angular 7 web application with Firebase database integration. In my code, I am attempting to store the initial list in an array using the subscribe method and then display that array using console.log(). However, there seems to be a ...

Submitting a form using an anchor tag in Angular 8: A step-by-step guide

I have a question about how to submit form data using hidden input fields when a user clicks on an <a> tag. <form action="/submit/form/link"> <input type="hidden" [attr.value]="orderNumber.id" /> <input type="hidden" [attr.value]= ...

Angular styling for input elements that are in the pristine state

Hey there, I'm working with a CSS class that applies a red border to an input field when it is required and invalid, and changes to green when it becomes valid. CSS .ng-valid[required], .ng-valid.required { border-left: 5px solid #42A948; /* green ...

Using React Material UI icon within an auto complete feature

https://i.stack.imgur.com/W3CmF.png I am struggling to incorporate the target icon into the autoComplete component. After reviewing the documentation, I have been unable to find a solution. In TextInput, a similar outcome can be achieved by implementing ...

What could be the reason behind my Ionic app receiving a 401 error from an API call while Postman is not encountering the

Following the instructions from a tutorial on Smart of the Home, I implemented the code below in a provider for my Ionic 2 App. return new Promise(resolve => { // Using Angular HTTP provider to make a request and process the response let headers = ...

The application has encountered an unexpected error and is currently unavailable

This is the code snippet for my MainActivity.java file. I am developing a simple LoginApp. However, when I try to run the app, it displays an "unfortunately stopped working ERROR..." message. package com.example.loginapp; import android.os.Bundle; import ...