Resizing cell height in an HTML table is not supported by Angular 5

In my angular application, I've implemented a component that represents a basic HTML table. However, I'm facing an issue with reducing the height of cells within the table. It seems like my CSS styling is not affecting the display as desired.

Here are the 'headers' and 'catNames' variables in my component.ts file:

catNames : string[] = ["Toto", "Tata", "Titi", "Mama", "Momo"];
headers: string[] = ["Head1", "Head2", "Head3", "Head4", "Head5"];

Below is the code snippet for my component's HTML structure:

<table>
  <tr>
    <th *ngFor="let header of headers">
        {{header}}
    </th>
  </tr>
  <tr>
    <td *ngFor="let cat of catNames">
        <p>{{cat}}</p>
    </td>
  </tr>
</table>

Here's my CSS styles for the table and its elements:

table {
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    border-collapse: collapse;
    text-align: center;
    width: 100%;
    font-size: 12pt;
}

th {
    border: 1px solid #dddddd;
    text-align: center;
    padding: 0px;
    color: white;
    background-color: dodgerblue;
}

td {
    display: table-cell;
    border: 1px solid #dddddd;
    text-align: center;
    margin: 0;
    padding: 0;
    border-spacing: 0;
}

The current display shows extra space on the top and bottom borders of the cell. How can I remove this unwanted spacing?

Could there be any mistakes in my CSS values that are causing this issue?

Answer №1

It is recommended to avoid using the <P> tag as it adds padding by default. If you still need padding, consider giving a negative value which is not ideal. The best approach would be to remove the <p> tags and use interpolation for text instead. Alternatively, you can apply CSS styles directly to the <p> element instead of using a table cell.

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

Having trouble with my ReactJS application where click interactions are functioning properly on the header but not on my content

Objective: Implement an iframe displaying a YouTube video with play/pause functionality for users. Issue: Unable to interact with main content, but works correctly when placed in Navigation or Footer components. Attempted Solutions: Explored various de ...

Shake up your background with a random twist

Seeking assistance with customizing the Aerial template from HTML5UP. I am interested in selecting a scrolling background randomly from a pool of images. Can someone guide me on how to achieve this? Presently, the background is defined within a code block ...

Retrieve the service variable in the routing file

How do I access the service variable in my routing file? I created a UserService with a variable named user and I need to use that variable in my routing file. Here is the approach I tried, but it didn't work: In the routing file, I attempted: cons ...

What is the best way to adjust text to a specific width on an HTML canvas?

Is there a way to adjust the width of a single-line text string precisely on an HTML5 canvas? My current method involves initially setting a font size, measuring the text's width using measureText(my_text).width, and then determining a new font size b ...

React, facing the challenge of preserving stored data in localStorage while accounting for the impact of useEffect upon

Seeking some assistance with the useEffect() hook in my Taking Notes App. I've set up two separate useEffects to ensure data persistence: one for when the page first loads or refreshes, and another for when a new note is added. I've added some l ...

Dealing with the overflow issue on Android 4.1 using position: relative and position: absolute

I have a question regarding creating a dynamically filling rounded button. I have successfully created an inner div inside the button with absolute positioning at the bottom. It works perfectly on Chrome webview, but I'm facing issues on Android 4.1. ...

Rearrange the order of divs dynamically to prevent wrapping/overflow, no need for media queries

Can someone help me with this issue? I am trying to create a navigation bar with centered menus/links, a logo on the left, and call-to-action buttons and icons on the right. If the content overflows or wraps, I want the center column to move to the next l ...

Using jQuery to establish a canvas element and define its dimensions by adjusting its width and height attributes

My attempt at using jQuery to create a canvas element was not quite as expected. Here is the code I tried: var newCanvas = $('<canvas/>',{'width':100,'height':200,'class':'radHuh'}); $(body).append(n ...

Can you identify the selected item on the menu?

My goal is to highlight the menu item for the current page by adding a "current" class. I've tried several code snippets from this website, but most of them didn't work as expected. The code I'm currently using almost works, but it has a sma ...

ngx: navigate to the specified URL once the user has been successfully logged in

I am faced with a dilemma where I must wait for my authentication server to return my token before calling my APIs. I am looking for a solution to ensure that my authState.token is not null before dispatching LoadMyStuffFromApi. I have implemented two res ...

Defining the active element in the menu using JavaScript

I need help with my navigation menu: <ul> <li id="active"><a href="/">Home</a></li> <li><a href="/about/">About Us</a></li> <li><a href="/services/">Our Services</a>< ...

Troubleshooting Observable data in Angular 2/Typescript - A Comprehensive Guide

After going through the Angular 2 tutorial, I managed to create a search feature that asynchronously displays a list of heroes. <div *ngFor="let hero of heroes | async"> {{hero.name}} </div> In my component, I have an observable array of ...

Is it possible to resize the background-image style?

When using the regular img tag in HTML, you can specify the width and height, and the browser will scale the image. If the dimensions are not too different from the original, the result is usually decent. For example, you can scale the avatar image to 32x ...

Is there a way to change the background color of product blocks on Shopify in a dynamic

Is there a way to customize the background colors of product blocks on Shopify by modifying the shop code? Take a look at this example: Mockup showing alternating block backgrounds Currently, all product blocks in the grid have a black background with wh ...

Aligning the tooltip element vertically

I've created a unique flexbox calendar layout with CSS tooltips that appear on hover. One challenge I'm facing is vertically aligning these tooltips with the corresponding calendar dates effectively. Although I prefer to achieve this alignment u ...

When attempting to import css-animator in Angular2/Typescript, a 404 error is displayed, indicating that the

Recently, I delved into the world of Angular2 and decided to experiment with some animations using css-animator package.json "dependencies": { "@angular/common": "2.0.0-rc.3", "@angular/compiler": "2.0.0-rc.3", "@angular/core": "2.0.0-rc.3", ...

Efficient Techniques to Eliminate Unwanted Jumping in CSS Transitions

I am currently working on a unique "stack" component that is inspired by the amazing ElastiStack. You can check out a cool demo of my work here. The demo works flawlessly on desktop Chrome, but unfortunately, I have encountered some issues with the transit ...

Tips on refining API response using Angular 2's HTTP module

This is the data I received from my transactions API: [{ "id": 1, "description": "Sandwich", "date": "2017-09-01", "category": "Take away", "tags": ["Holidays"], "amount": -2 },{ "id": 2, "description": "Wage", "date": "2017-08- ...

What impact does setting 'pathmatch: full' in Angular have on the application?

When the 'pathmatch' is set to 'full' and I try to delete it, the app no longer loads or runs properly. import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { H ...

Is your WordPress one-page scroll JQuery script failing to function properly?

Currently attempting to develop a single page scroll feature. Within WordPress, my navigation contains anchor tags structured as follows: <a href="#contact">Contact</a> <a href="#about">About</a> The corresponding divs for the li ...