Angular Material Flex is not providing the correct size

There seems to be a problem with certain values for setting the flex property in the Angular Material layout library.

The issue is clearly demonstrated in this straightforward example. By clicking through, you can observe that some values display correctly while others appear to be illogical.

If you are interested, you can view the demonstration here: http://codepen.io/anon/pen/RaQzxr

Has anyone encountered this issue before and found a solution?

<div ng-cloak ng-app="MyApp">

  <div layout="row">
    <md-card flex="10">
      <h2>Card title #1</h2>
      <md-card-content>
        <p>This should be 10%!</p>
      </md-card-content>
    </md-card>
    <md-card flex>
    </md-card>
  </div>
  <div layout="row" layout-xs="column">
    <md-card flex="11">
      <h2>Card title #1</h2>
      <md-card-content>
        <p>This should be 11%!</p>
      </md-card-content>
    </md-card>
    <md-card flex>
    </md-card>
  </div>
  <div layout="row" layout-xs="column">
    <md-card flex="12.5">
      <h2>Card title #1</h2>
      <md-card-content>
        <p>This should be 12.5%!</p>
      </md-card-content>
    </md-card>
    <md-card flex>
    </md-card>
  </div>
  <div layout="row" layout-xs="column">
    <md-card flex="15">
      <h2>Card title #1</h2>
      <md-card-content>
        <p>This should be 15%!</p>
      </md-card-content>
    </md-card>
    <md-card flex>
    </md-card>
  </div>
  <div layout="row" layout-xs="column">
    <md-card flex="16">
      <h2>Card title #1</h2>
      <md-card-content>
        <p>This should be 16%!</p>
      </md-card-content>
    </md-card>
    <md-card flex>
  </div>
  <div layout="row" layout-xs="column">
    <md-card flex="19">
      <h2>Card title #1</h2>
      <md-card-content>
        <p>This should be 19%!</p>
      </md-card-content>
    </md-card>
    <md-card flex>
    </md-card>
  </div>
  <div layout="row" layout-xs="column">
    <md-card flex="20">
      <h2>Card title #1</h2>
      <md-card-content>
        <p>This should be 20%!</p>
      </md-card-content>
    </md-card>
    <md-card flex>
    </md-card>
  </div>
</div>

Answer №1

According to the Angular Material website, a layout child's flex directive can have an integer value ranging from 0 to 100. This means that the element will expand to the specified percentage of available space. Currently, the flex directive value is limited to multiples of five, with exceptions for 33 and 66.

Click here to learn more.

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

Issue with reloading when using AngularJS routing

I'm encountering numerous difficulties with AngularJs routing. Even after researching online, I still find the solutions provided unclear. Here is my current routing block: var myApp = angular.module('myApp', ["ngRoute", "ngAnimate"]); myA ...

After updating to version 13 of Angular and Angular Material, the mat-contenteditable feature has ceased functioning

Encountered errors with mat-contenteditable after updating Angular from version 12 to 13 Error: /node_modules/mat-contenteditable/lib/mat-ckeditor.directive.d.ts:9:22 - error TS2420: Class 'MatCkeditorDirective' incorrectly implements interface & ...

Ignoring templateUrl in AngularJS and Karma-Jasmine to prevent the occurrence of "Unexpected request: GET .../.html" error

Currently, I am developing an AngularJS application using ES6 in order to minimize the amount of work needed for transitioning to AngularJS 2.0. However, I have encountered some complexity when it comes to performing unit tests. My main focus now is to t ...

Managing various swipe interactions using HTML and JavaScript/jQuery

I'm in the process of creating a mobile multiplayer game using HTML5 and Javascript. The jQuery Plugin "touchwipe" is utilized to manage swipe events in various divs like this: $('#play1').touchwipe({ wipeLeft: function(){ if ...

Iterating through a jQuery function to increment value

I have encountered an issue while trying to calculate the total value from an array of form fields. The problem lies in how the final value is being calculated on Keyup; it seems that only the last inputted value is being added instead of considering all t ...

Eliminate the need for pressing the "tab" key on my website

I'm currently working on a horizontal web page layout and I'm looking for a way to disable the "tab" button functionality on my page. The issue arises because I have a contact form with textboxes located in the last div, and when users navigate u ...

Create a navigation link in Vue-bootstrap that directs to an 'external program'

After deciding to use vue-bootstrap instead of just bootstrap for its additional features like tabs, I made the choice to rewrite the navigation using it as well. However, I encountered an issue where the links in the navigation menu are pointing to the co ...

Number input in JavaScript being disrupted by stray commas

On my webpage, there are elements that users can control. One of these is a text input field for numbers. When users enter digits like 9000, everything functions correctly. However, if they use comma notation such as 9,000, JavaScript doesn't recogniz ...

"Want to learn how to dynamically disable an input field in AngularJS when another field is selected? Find out how to achieve this using the

Hey there, I'm dealing with two input fields. Input field A is a drop-down menu and input field B. They both have the same value (same ng-model). My goal is to clear the second input field whenever the user selects an option from the dropdown. Can any ...

What method does Express use to determine which Router path to follow if there are multiple matching paths?

If there are 2 router.route() methods, like the examples below: router.route('/app/:id').get(function(req, res, next){ console.log("id route"); }); and router.route('/app/:username').get(function(req, res, next){ console.log ...

Hiding elements in FireBase and Angular based on user identification

Currently venturing into the world of Firebase in conjunction with AngularJS after previously working with php and server-side rendered pages. I am grappling with how to securely hide specific parts of an application from certain users. I have three disti ...

objects bound to knockout binding effects

I have been struggling to understand why the binding is not working as expected for the ‘(not working binding on click)’ in the HTML section. I have a basic list of Players, and when I click on one of them, the bound name should change at the bottom of ...

Addressing the issue of Google Charts legends overlapping

As a newcomer to Stackoverflow and Google Charts, I am encountering an issue in one of my projects that utilizes the Google Charts API. Specifically, I am trying to display two legends on the chart but they are overlapping in the preview. Despite explorin ...

Experiencing Issues with File Downloading on Express Server with Axios and Js-File-Download Library

I developed a feature on my express server that allows users to download a file easily. app.post("/download", (req, res) => { let file_name = req.body.name; res.download(path.join(__dirname, `files/${file_name}.mp3`), (err) => { ...

A DropdownListFor with a predefined value using ng-model

I am currently working on creating a DropdownList using the code snippet below. However, I am facing an issue where the default text "Select Product/Program..." is not being set in the dropdown. Strangely, when I remove the ng-model, it works correctly. Do ...

Show or hide the expand/collapse button based on the height of the container

Looking for a way to hide content in a Div if it's taller than 68px and display an expand option? The challenge lies in detecting the height of the responsive Div, especially since character count varies. I attempted using PHP to count characters bu ...

MUI: How can I resolve the issue of TextField not supporting the number type with maxLength restriction?

I am currently facing an issue with applying maxLength to the TextField component when the type is set to number. Here is my code snippet: const CustomTextField = ({ label, value, maxLength, required, disabled, handleChange, ha ...

Tips for building forms with VUE?

Today is my first attempt at learning VUE, and I've decided to follow a tutorial on YouTube from freeCodeCamp.org. The tutorial covers the concept of components in VUE, specifically focusing on creating a login form project. Despite following the ins ...

Utilizing a custom function declared within the component to handle changes in Angular's ngOnChanges

Although it may seem like a simple question, I'm struggling to find a solution. Here's the issue at hand: In my Angular Component, there's a function that I need help with. export class RolesListComponent implements OnInit, OnChanges { ...

Setting up TailwindCSS in Nuxt3: A step-by-step guide

Looking to customize the default font Proxima Nova from TailwindCSS in my Nuxt3 project but navigating the file structure is a bit tricky for me. I've gone ahead and installed the tailwindcss module: npm i -D @nuxtjs/tailwindcss and added the module ...