show data in a table that has additional margin at the top

I attempted to create a component similar to the input-group in bootstrap. I opted not to use the default input-group class of bootstrap because it doesn't allow for adding multiple buttons and input elements in the input group addon. Therefore, I decided to create a custom input-group using the display-table property. However, when I implemented this property, some extra space was added to the top in the buttons section.

My goal is to align the input and counter components on the same line.

HTML Part

 <div class="product-order-form" matAutocompleteOrigin #origin="matAutocompleteOrigin">
    <div class="product-inputGroup tableElem">
        <div class="tableRow">
            <input class="form-control tableCell" type="text" matInput [formControl]="myControl" [matAutocomplete]="auto" [matAutocompleteConnectedTo]="origin">
            <div class="counter tableCell">
                <div class="counterContainer">
                    <div class="value-button" id="decrease" value="Decrease Value">-</div>
                    <input type="text" id="number" value="0" />
                    <div class="value-button" id="increase" value="Increase Value">+</div>
                </div>


            </div>
        </div>


    </div>
 </div>

CSS:

.tableElem{
  display:table;
  width:100%;
}

.tableRow{
  display:table-row;
  width:100%;
}
.tableCell{
  display:table-cell;
}

.product-order-form{
  height: 30px;
}
.counterContainer {
  width: 150px;
  height:30px;  
}

.value-button{
    text-align: center;
    height: 100%;
    width: 50px;
    background: lightgray;
    padding: 5px;
    box-sizing: border-box;
    float: left;
}

.value-button:hover {
  cursor: pointer;
}



input#number{
    text-align: center;
    height: 100%;
    border: none;
    width: 50px;   
    float: left;   
    box-sizing: border-box;
    border-top: 0.5px solid lightgray;
    border-bottom: 0.5px solid lightgray;
}

For more information, please visit my StackBlitz project.

Answer №1

Here are a couple of issues that need to be addressed:

  1. The height set for .product-order-form is only 30px, which is shorter than some of its children/siblings. This could lead to problems (you can test by adding overflow:hidden to observe the effect)
  2. The .tableCell element lacks a vertical-align property, causing it to align itself at the top of the component. Adding vertical-align: middle should resolve this issue.

TL;DR


.tableCell[_ngcontent-c2] {
    display: table-cell;
    vertical-align: middle;
}
.product-order-form[_ngcontent-c2]{
    height: auto;
}

This adjustment should solve the problem :)

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

The backdrop takes precedence over all other elements

The issue I'm facing is that the other Div is not appearing above the background. My goal is to have the background fill the entire screen. <title>The Ultimate Cube World Resource!</title> <link href="style.css" rel="stylesheet" type=" ...

The footer lies at the bottom of the page, demarcated by

I'm struggling to position the footer at the bottom of the page with a horizontal line just above it. Despite trying various resources, I can't seem to get the footer to stay at the bottom. I'm currently using a blog template as the basis fo ...

Height of the div dynamically increases upwards

Just a quick question - is there a way to make position: fixed divs at the bottom of an element (such as the body) grow upwards as content is dynamically added? Maybe something like anchor: bottom or increase: up? I'm thinking that using JavaScript m ...

The HTML pattern [A-Za-z] specifies that the entered name must adhere to the required format, such as inputting "john"

<div class="title details"> <label for="idtitle" class="label">Title</label> <input type="text" placeholder="Title" id="idtitle" pattern="[A-Za-z]" required> </div> Link to Firefox screenshot ...

How to align a Bootstrap form to the center

Struggling to center the opt-in form on my website, I've created a "center" class with margin properties but it's not working as expected. .center { margin-left: auto; margin-right: auto; width: 100% } I suspect that one of Bootstrap's cla ...

What is causing my sprite image to be cropped?

I'm currently working on implementing a progress bar handle for my website. While the progress bar functions perfectly, I'm encountering an issue where the handle gets cut off when placed above the bar. Please refer to the attached image for refe ...

Scroll through the div to quickly find the relevant content

I have implemented the following HTML structure: <div style="height:200px;overflow-y:scroll;"> <table>.....</table> </div> By using this setup, I am aiming to replicate the functionality of an expanded <select> control wit ...

Extract the URL of the background image from a preexisting <div> element, or append a new attribute to the background-image property

I am facing a challenge in updating the existing background-image with a linear gradient. Currently, my CMS is generating a background-image, but I am unable to adjust the opacity using a linear gradient. My goal is to darken the background-image using CSS ...

Mastering the fundamentals of integrating/augmenting a fresh template in Umbraco

Let me be completely honest. Umbraco is unlike any other CMS I have worked with before. I am currently struggling to grasp the proper method of creating a Template and integrating it into Umbraco. How exactly can I add a template? I am making changes to t ...

Trouble aligning two columns in a row with Bootstrap 4

Hey there! I've encountered an issue with my login form using bootstrap 4. I have set up two col-md-6 columns in a row for "Remember Me" and "Forgot Password", but on mobile devices, the "Forgot Password" section jumps down from the row. Can anyone sh ...

Create multiple buttons with uniform width by adjusting padding in CSS

I recently attempted to create buttons using CSS and padding. Here is the HTML code for the buttons: <link rel="stylesheet" type="text/css" href="css/style-login.css" /> <link rel="stylesheet" type="text/css" href="css/font-awesome-4.0.3.css" /& ...

Tips on halting the current animation and modifying styles upon hovering

Currently, I have a basic label featuring a contact number with a blinking animation. However, the animation is only a simple color transition at this time (see code below). I have managed to successfully pause the animation and revert the text back to it ...

What is the best way to design a Bootstrap grid layout that includes a responsive left column with a minimum width and a scrollable right column?

I'm so close to getting the desired look and behavior, but I'm facing a problem with the scrolling in the right column. The scrollbar is visible but it's not scrolling the content on the right side. It should look like this: . Currently, i ...

Attempting to replicate a <textarea> to behave like a <div> element

I am currently facing an issue with my HTML and CSS code. I have tried to construct a design using a <div> but it resulted in horizontal scrolling and looked chaotic. How can I make the CSS and HTML look the same without any issues? <textarea c ...

`Unaligned headers`

Encountering an issue with jQuery DataTables where the header of the table is not aligned properly with the body when the table has a horizontal scroll bar and the width is increased. Here is the original datatable without resizing: And here is the datat ...

Transitioning Menus with Submenu Animation

After following a CSS menu tutorial and customizing it, two issues have arisen. When hovering over the "About" menu with additional list links, the transition works but then the content shifts to the left and fades out. The second issue is related to tryin ...

Javascript problem: Understanding the .children method and how to use it

I have implemented a basic JavaScript/CSS code to show a tooltip/enlarged photo feature. You can visit the actual page here. The thumbnail images are located on the right-hand side. The issue I am facing is that when using the mouseenter function, the to ...

The placement of blocks, the positioning of text, and the underlining of links

Attempting to implement pagination on one of my websites has posed a challenge for me due to my average CSS skills. You can view the issue I'm facing in this example: http://jsfiddle.net/rmurzea/qE7Ku/3/ 1). I had to add the margin-bottom property t ...

Execute a jQuery function every time the class of the parent container div changes

I am seeking to trigger the function below whenever its containing div parent <div class="section">...</div> transitions to an "active" state, for example: <div class="section active">...</div> $(".skills-grid__col").each(function ...

Attempting to position the calendar control at the center in Visual Studio using C#

I'm currently working in Visual Studio using C# and I've encountered an issue with centering a Calendar control within a Panel. While I have successfully centered other elements such as radiobuttons, checkboxes, and textboxes in the panel, the t ...