Editing Angular Material's Table Cell Padding





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







5















When I inspect the element with developer tools it shows zero padding, but when I look a it and mouse over it, it very clearly has padding within the cell. I have no idea where this is coming from, and setting
td { padding: 0 !important } does nothing.










share|improve this question































    5















    When I inspect the element with developer tools it shows zero padding, but when I look a it and mouse over it, it very clearly has padding within the cell. I have no idea where this is coming from, and setting
    td { padding: 0 !important } does nothing.










    share|improve this question



























      5












      5








      5








      When I inspect the element with developer tools it shows zero padding, but when I look a it and mouse over it, it very clearly has padding within the cell. I have no idea where this is coming from, and setting
      td { padding: 0 !important } does nothing.










      share|improve this question
















      When I inspect the element with developer tools it shows zero padding, but when I look a it and mouse over it, it very clearly has padding within the cell. I have no idea where this is coming from, and setting
      td { padding: 0 !important } does nothing.







      css angular angular-material






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 23 '18 at 8:20









      Willi Mentzel

      10.8k115071




      10.8k115071










      asked Jun 5 '18 at 21:41









      yoursweateryoursweater

      376417




      376417
























          1 Answer
          1






          active

          oldest

          votes


















          4














          The perceived padding is being caused by display: table-cell; and vertical-align: inherit; (which usually is value middle) from the default browser/user-agent <td> styles in combination with a height being set on the tr.mat-row. The <tr> with CSS class .mat-row has a set height by default of 48px. You can adjust the height or set to height: auto; then adjust padding to the td.mat-cell as needed. This effectively removes the perceived padding that is visible when inspecting with developer tools. The green padding visualization seen in something like Chrome developer tools when inspecting the <td> is how just a middle vertically aligned element with table-cell is displayed in the tools. If you examine the Computer properties of that <td> you'll see it has zero padding on all four sides.



          .mat-row {
          height: auto;
          }

          .mat-cell {
          padding: 8px 8px 8px 0;
          }


          Here is a StackBlitz showing the height: auto; on tr.mat-row as well as a custom padding value on td.mat-cell in action.



          While I'd recommend to avoid changing the display property value on td.mat-cell, you can change it to something like inline-block to see the effects without any adjustments to height of mat-row.



          Hopefully that helps!






          share|improve this answer


























          • This only works for me with !important on the padding, as the code for the mat-table is apparently written directly into a <style> block.

            – Steve
            Dec 14 '18 at 14:31











          • @Steve, it would depend on where you put your styles. If you use styleUrls, as the example in the answer does, component CSS styles are encapsulated in the component's view and don't require the !important tag as selectors such as table[_ngcontent-c6] are created. If you are using global CSS, you may have to increase specificity or use !important as you mentioned.

            – Alexander Staroselsky
            Dec 14 '18 at 14:53













          • Yes, we are trying to avoid component styles and have a global css file for people using Angular Material (as most of our company uses Bootstrap).

            – Steve
            Dec 14 '18 at 18:35












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50709363%2fediting-angular-materials-table-cell-padding%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          The perceived padding is being caused by display: table-cell; and vertical-align: inherit; (which usually is value middle) from the default browser/user-agent <td> styles in combination with a height being set on the tr.mat-row. The <tr> with CSS class .mat-row has a set height by default of 48px. You can adjust the height or set to height: auto; then adjust padding to the td.mat-cell as needed. This effectively removes the perceived padding that is visible when inspecting with developer tools. The green padding visualization seen in something like Chrome developer tools when inspecting the <td> is how just a middle vertically aligned element with table-cell is displayed in the tools. If you examine the Computer properties of that <td> you'll see it has zero padding on all four sides.



          .mat-row {
          height: auto;
          }

          .mat-cell {
          padding: 8px 8px 8px 0;
          }


          Here is a StackBlitz showing the height: auto; on tr.mat-row as well as a custom padding value on td.mat-cell in action.



          While I'd recommend to avoid changing the display property value on td.mat-cell, you can change it to something like inline-block to see the effects without any adjustments to height of mat-row.



          Hopefully that helps!






          share|improve this answer


























          • This only works for me with !important on the padding, as the code for the mat-table is apparently written directly into a <style> block.

            – Steve
            Dec 14 '18 at 14:31











          • @Steve, it would depend on where you put your styles. If you use styleUrls, as the example in the answer does, component CSS styles are encapsulated in the component's view and don't require the !important tag as selectors such as table[_ngcontent-c6] are created. If you are using global CSS, you may have to increase specificity or use !important as you mentioned.

            – Alexander Staroselsky
            Dec 14 '18 at 14:53













          • Yes, we are trying to avoid component styles and have a global css file for people using Angular Material (as most of our company uses Bootstrap).

            – Steve
            Dec 14 '18 at 18:35
















          4














          The perceived padding is being caused by display: table-cell; and vertical-align: inherit; (which usually is value middle) from the default browser/user-agent <td> styles in combination with a height being set on the tr.mat-row. The <tr> with CSS class .mat-row has a set height by default of 48px. You can adjust the height or set to height: auto; then adjust padding to the td.mat-cell as needed. This effectively removes the perceived padding that is visible when inspecting with developer tools. The green padding visualization seen in something like Chrome developer tools when inspecting the <td> is how just a middle vertically aligned element with table-cell is displayed in the tools. If you examine the Computer properties of that <td> you'll see it has zero padding on all four sides.



          .mat-row {
          height: auto;
          }

          .mat-cell {
          padding: 8px 8px 8px 0;
          }


          Here is a StackBlitz showing the height: auto; on tr.mat-row as well as a custom padding value on td.mat-cell in action.



          While I'd recommend to avoid changing the display property value on td.mat-cell, you can change it to something like inline-block to see the effects without any adjustments to height of mat-row.



          Hopefully that helps!






          share|improve this answer


























          • This only works for me with !important on the padding, as the code for the mat-table is apparently written directly into a <style> block.

            – Steve
            Dec 14 '18 at 14:31











          • @Steve, it would depend on where you put your styles. If you use styleUrls, as the example in the answer does, component CSS styles are encapsulated in the component's view and don't require the !important tag as selectors such as table[_ngcontent-c6] are created. If you are using global CSS, you may have to increase specificity or use !important as you mentioned.

            – Alexander Staroselsky
            Dec 14 '18 at 14:53













          • Yes, we are trying to avoid component styles and have a global css file for people using Angular Material (as most of our company uses Bootstrap).

            – Steve
            Dec 14 '18 at 18:35














          4












          4








          4







          The perceived padding is being caused by display: table-cell; and vertical-align: inherit; (which usually is value middle) from the default browser/user-agent <td> styles in combination with a height being set on the tr.mat-row. The <tr> with CSS class .mat-row has a set height by default of 48px. You can adjust the height or set to height: auto; then adjust padding to the td.mat-cell as needed. This effectively removes the perceived padding that is visible when inspecting with developer tools. The green padding visualization seen in something like Chrome developer tools when inspecting the <td> is how just a middle vertically aligned element with table-cell is displayed in the tools. If you examine the Computer properties of that <td> you'll see it has zero padding on all four sides.



          .mat-row {
          height: auto;
          }

          .mat-cell {
          padding: 8px 8px 8px 0;
          }


          Here is a StackBlitz showing the height: auto; on tr.mat-row as well as a custom padding value on td.mat-cell in action.



          While I'd recommend to avoid changing the display property value on td.mat-cell, you can change it to something like inline-block to see the effects without any adjustments to height of mat-row.



          Hopefully that helps!






          share|improve this answer















          The perceived padding is being caused by display: table-cell; and vertical-align: inherit; (which usually is value middle) from the default browser/user-agent <td> styles in combination with a height being set on the tr.mat-row. The <tr> with CSS class .mat-row has a set height by default of 48px. You can adjust the height or set to height: auto; then adjust padding to the td.mat-cell as needed. This effectively removes the perceived padding that is visible when inspecting with developer tools. The green padding visualization seen in something like Chrome developer tools when inspecting the <td> is how just a middle vertically aligned element with table-cell is displayed in the tools. If you examine the Computer properties of that <td> you'll see it has zero padding on all four sides.



          .mat-row {
          height: auto;
          }

          .mat-cell {
          padding: 8px 8px 8px 0;
          }


          Here is a StackBlitz showing the height: auto; on tr.mat-row as well as a custom padding value on td.mat-cell in action.



          While I'd recommend to avoid changing the display property value on td.mat-cell, you can change it to something like inline-block to see the effects without any adjustments to height of mat-row.



          Hopefully that helps!







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 5 '18 at 22:15

























          answered Jun 5 '18 at 21:50









          Alexander StaroselskyAlexander Staroselsky

          14.3k42343




          14.3k42343













          • This only works for me with !important on the padding, as the code for the mat-table is apparently written directly into a <style> block.

            – Steve
            Dec 14 '18 at 14:31











          • @Steve, it would depend on where you put your styles. If you use styleUrls, as the example in the answer does, component CSS styles are encapsulated in the component's view and don't require the !important tag as selectors such as table[_ngcontent-c6] are created. If you are using global CSS, you may have to increase specificity or use !important as you mentioned.

            – Alexander Staroselsky
            Dec 14 '18 at 14:53













          • Yes, we are trying to avoid component styles and have a global css file for people using Angular Material (as most of our company uses Bootstrap).

            – Steve
            Dec 14 '18 at 18:35



















          • This only works for me with !important on the padding, as the code for the mat-table is apparently written directly into a <style> block.

            – Steve
            Dec 14 '18 at 14:31











          • @Steve, it would depend on where you put your styles. If you use styleUrls, as the example in the answer does, component CSS styles are encapsulated in the component's view and don't require the !important tag as selectors such as table[_ngcontent-c6] are created. If you are using global CSS, you may have to increase specificity or use !important as you mentioned.

            – Alexander Staroselsky
            Dec 14 '18 at 14:53













          • Yes, we are trying to avoid component styles and have a global css file for people using Angular Material (as most of our company uses Bootstrap).

            – Steve
            Dec 14 '18 at 18:35

















          This only works for me with !important on the padding, as the code for the mat-table is apparently written directly into a <style> block.

          – Steve
          Dec 14 '18 at 14:31





          This only works for me with !important on the padding, as the code for the mat-table is apparently written directly into a <style> block.

          – Steve
          Dec 14 '18 at 14:31













          @Steve, it would depend on where you put your styles. If you use styleUrls, as the example in the answer does, component CSS styles are encapsulated in the component's view and don't require the !important tag as selectors such as table[_ngcontent-c6] are created. If you are using global CSS, you may have to increase specificity or use !important as you mentioned.

          – Alexander Staroselsky
          Dec 14 '18 at 14:53







          @Steve, it would depend on where you put your styles. If you use styleUrls, as the example in the answer does, component CSS styles are encapsulated in the component's view and don't require the !important tag as selectors such as table[_ngcontent-c6] are created. If you are using global CSS, you may have to increase specificity or use !important as you mentioned.

          – Alexander Staroselsky
          Dec 14 '18 at 14:53















          Yes, we are trying to avoid component styles and have a global css file for people using Angular Material (as most of our company uses Bootstrap).

          – Steve
          Dec 14 '18 at 18:35





          Yes, we are trying to avoid component styles and have a global css file for people using Angular Material (as most of our company uses Bootstrap).

          – Steve
          Dec 14 '18 at 18:35




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50709363%2fediting-angular-materials-table-cell-padding%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?