Utilizing the "row" and "column" attributes in Angular (Flexbox) results in significant spacing between input fields within the HTML code

I'm working on aligning 2 input fields side by side within the same line. To achieve this, I've been utilizing Flexbox. However, I've observed that when using Flex with both 'row' and 'column', it introduces extra spacing as shown in the image below:

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

Here is the code structure:

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

apidefs-disp.component.html

<div class="flex-disp-apidefs-container">
    <div class="flex-disp-apidefs-list">

        <kdc-apidefs-list></kdc-apidefs-list> 
    </div>
    <div class="flex-disp-apidefs-form">
        <kdc-apidefs-form></kdc-apidefs-form> 
    </div>
</div

apidefs-form.component.html

        <div class="row">

            <!-- Name -->
            <div class="col">
                <div class="md-form">

                    <input required type="text" id="materialapidefsFormName" class="form-control"
                        aria-describedby="materialapidefsFormNameHelpBlock" mdbInput formControlName="name" />

                    <label for="materialapidefsFormName">Name</label>
                    <mat-error
                        *ngIf="apidefsForm.controls['name'].hasError('required') && apidefsForm.controls.name.touched">
                        Name is required
                    </mat-error>

                    <mat-error
                        *ngIf="apidefsForm.controls['name'].hasError('maxLength') && apidefsForm.controls.name.touched">
                        maximum Length is 25
                    </mat-error>
                </div>
            </div>

            <!-- Description -->
            <div class="col">
                <div class="md-form">

                    <input required type="text" id="materialapidefsFormDescription" class="form-control"
                        aria-describedby="materialapidefsFormDescriptionHelpBlock" mdbInput
                        formControlName="description" />

                    <label for="materialapidefsFormDescription">Description</label>
                    <mat-error
                        *ngIf="apidefsForm.controls['description'].hasError('required') && apidefsForm.controls.description.touched">
                        Description is required
                    </mat-error>

                    <mat-error
                        *ngIf="apidefsForm.controls['description'].hasError('maxLength') && apidefsForm.controls.description.touched">
                        maximum Length is 50
                    </mat-error>
                </div>
            </div>
        </div>

[... snip ...]

apidefs-disp.component.scss

.flex-disp-apidefs-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    flex: auto;
}

.flex-disp-apidefs-list {
    display: flex;
    flex-direction: column; 
    //width:100%;
    flex:2;
}

.flex-disp-apidefs-form {
    display: flex;
    flex-direction: column; 
    //width: 100%;
    flex:4;
}

apidefs-list.component.scss

NOTHING

apidefs-form.component.scss

.text-center {
    width: 100%;
}

 .flex-apidefs-form{
    display:flex;
    width: 100%;
    padding: 30px;
    background-color: var(--accent-lighter-color);

 }

QUESTION: Is there a way to reduce the vertical space between two sets of input fields?

Any assistance, suggestions, or tips would be highly appreciated.

TIA

ETA I recently encountered an issue while trying to copy the code to Stackblitz (seems like it's related to a paid product - unsure if it should be included in StackBlitz).

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

Looking for solutions to address this problem...

Answer №1

I made a change to the CSS by switching the display property from 'flex' to 'grid'. This adjustment proved to be more user-friendly as it eliminated the need to define row and col repeatedly. Additionally, I discovered that the class md-form contained unnecessary padding which was affecting the layout (similar to a previous issue I encountered with the html p tag). To address this, I implemented the following:

.grid-apidefs-form .md-form {
    margin: 0em;
    height: 4em;
}

This code effectively reset the margin to 0 and set a new height of 4em for the element.

As a result, all functionalities are now operating correctly.

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

There is no valid injection token found for the parameter 'functions' in the class 'TodosComponent'

While working in my code, I decided to use 'firebase' instead of '@angular/fire'. However, I encountered an issue that displayed the following error message: No suitable injection token for parameter 'functions' of class &apos ...

Is it possible to maintain a fixed footer while utilizing async/ajax functions?

Looking for a reliable solution to have a fixed footer that adjusts based on the page content? I've tested multiple samples, but they all fall short when it comes to incorporating AJAX elements. Is there a fixed footer out there that truly works seaml ...

Establishing the destination for an onclick event to a designated spot

I have divided my body content into two parts. The left side contains a map and buttons, where clicking on a button displays results from Arad.php in another window. How can I target the second half (split right) of my body? <body> <div cla ...

What sets apart exporting a component from importing its module in another module?

When working with Angular, consider having both module A and module B. If I intend to utilize "A-component" within components of module B, what is the distinction between importing module A in Module B compared to including the "A-component" in the exports ...

Struggling to choose an element within $(this) despite being able to view it in the $(this) outerHTML

I have a question regarding jQuery 1.12. I am attempting to target an element within $(this). $(".select").bind('keydown', function(event) { elt = $(this)[0]; console.log(elt.outerHTML); elt = $(this)[0].search("li") console.log ...

Align both the image and text in the center with no space between

How can I center two blocks containing both images and text vertically and horizontally while using flexbox? I notice that when the text is longer, padding appears between the image and the text. How can I remove this padding?1 .product-teaser { width ...

Creating a customizable Sass Mixin for animation keyframes that incorporates various stages and the transform property

My goal is to generate the standard CSS using a SASS Mixin for efficiency. STANDARD CSS @-webkit-keyframes crank-up { 100% { -webkit-transform: rotate(360deg);} } @-moz-keyframes crank-up { 100% { -moz-transform: rotate(360deg);} } @-o-keyframes cran ...

Which architectural style is best to master for developing exceptional JavaScript software?

My familiarity with Model-View-Controller runs deep, having worked with it for years in server-side development using languages like PHP. Now, I find myself diving into JavaScript and embarking on a large project that utilizes SVG, Canvas, and other moder ...

Extracting data from an array using Angular

Currently, I am developing an Angular application that involves handling an array structured like the one below. [ { Code: "123", Details:[ { Id: "1", Name: "Gary" }, { ...

What is the best way to extract the numerical value from a JavaScript object?

I'm currently working on a web form for a currency exchange demonstration. I have included a snippet of HTML and Javascript code that I have initially implemented. <!DOCTYPE html> <html lang="en"> <head> <meta charset="ut ...

Is there a way to link two HTML files containing jQuery within an HTML index file?

I'm currently working on creating an index page for a pair of HTML files that utilize jquery. Let's break down the structure of these files: Emps1, Emps2: These are two HTML tables that start off empty. TabA_stats, TabB_stats: Each HTML file ha ...

Detecting coordinates (x, y) on a canvas

I'm currently working on a mini-game and encountering an issue with the player movement around the green square. My character seems to be unable to move past the x, y coordinates of the square, even though it can approach it closely. I would really ap ...

Adjust the CSS to give <a> elements the appearance of plain text

Is it possible to style an anchor tag to appear identical to plain text? Consider the following scenario: <p> Here is some text and here is a <a class='no-link' href="http://www.example.com" >link</a></p> I have atte ...

Tips for adjusting the horizontal position of a grid item within a map() loop

I am trying to align the text in my Timeline component from Material Ui always towards the center of the timeline. The TimelineContent contains Paper, Typography (for title and description), and an image. Currently, I have multiple TimelineContent element ...

Automatically navigate to a specific element as the user scrolls down the page

I am attempting to achieve a similar effect as seen on the App Builder Website. When the user reaches the header with the background image/video and scrolls down, the website smoothly transitions to the next div/section. If the user scrolls back up and ret ...

Hover effect triggered upon mouse exit

As I delve into learning the basics of HTML and CSS, I came across the :hover property in CSS. This unique feature allows for a specific action to occur when the cursor hovers over an element, based on the code provided. Additionally, I discovered the tran ...

Issue encountered while utilizing property dependent on ViewChildren

Recently, I designed a custom component which houses a form under <address></address>. Meanwhile, there is a parent component that contains an array of these components: @ViewChildren(AddressComponent) addressComponents: QueryList<AddressCo ...

Discovering the dimensions of a disabled attribute within a table using XPath in Selenium with Java

I'm attempting to determine the number of columns in a specific table, but some are disabled - I'd like to know if it's possible to get the count without including the disabled ones (only counting the visible columns). As you can see in the ...

Adjust tool tip text on the fly

As a beginner, I created a test table and now I want to make the tool tip text change dynamically when I hover over the table with my mouse. Ideally, I would like the tool tip text to correspond to the content of the table cell. Currently, I only have stat ...

When using the HTML a tag, it can create unexpected gaps and

I have a sentence written in PHP that I've separated into individual word components using the explode function. foreach ($words as $splitword) { echo $splitword; /* echo "<a href = 'word.php?word=" . $splitword . "'>" . $spli ...