Why is the size of this button smaller than the input box and not aligning in height even though they are both set to the same height of 5vh?

The submit button in the input box should ideally be the same size (5vh) and aligned at the same height as the input box, but it currently is not.

        html {
            height: 100%;
        }

        #box {
            height: 18.52vh;
            width: 72.92vw;
            background: #ffffff1a;
            display: flex;
            align-items: center;
            justify-content: center;
            border: thick solid red;
        }

        body {
            background-image: linear-gradient(#000000, rgb(119, 0, 0));
        }

        .container {
            margin: 0;
            position: absolute;
            top: 50%;
            left: 50%;
            -ms-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
        }

        .center {
            margin: 0;
            position: absolute;
            top: 50%;
            left: 50%;
            -ms-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
        }

        .butt {
            background-color: #9c0101a8;
            color: rgb(211, 211, 211);
            padding: 16px;
            font-size: 16px;
            border: none;
        }

        ::placeholder {
            /* Chrome, Firefox, Opera, Safari 10.1+ */
            color: rgb(0, 0, 0);
            opacity: 1;
            /* Firefox */
        }

        :-ms-input-placeholder {
            /* Internet Explorer 10-11 */
            color: rgb(0, 0, 0);
        }

        ::-ms-input-placeholder {
            /* Microsoft Edge */
            color: rgb(0, 0, 0);
        }

        .font_size_auto{
            font-size: clamp( 0px, 3.5vh, 3vw);
            font-family: times;
        }

        .font_size_auto_enter{
            font-size: clamp( 0px, 3.5vh, 1.8vw);
            font-family: times;
        }
<body>
    <div class="container">
        <div id="box">
            <form method="POST">
                <input name="text" class = "font_size_auto" style="color: #000000; background-color: #9c0101a8; border-color:rgb(0, 0, 0); height: 5vh; width: 20vw;" placeholder="enter name here">
                <button type="submit" class = "font_size_auto_enter" id="butt" style="text-align:center; width: 6vw; height: 5vh; background-color: #9c0101a8;">
                    enter
                </button>
            </form>
        </div>
    </div>


</body>

I'm not sure if this is breaking any rules, but I just need to include more text so that I can post the question since it's mostly code.

Answer №1

The button selector needs to be corrected in CSS. Make sure you use # instead of .

Your incorrect HTML and CSS

<button type="submit" class = "font_size_auto_enter" id="butt" style="text-align:center; width: 6vw; height: 5vh; background-color: #9c0101a8;">
                    enter
                </button>
.butt {
            background-color: #9c0101a8;
            color: rgb(211, 211, 211);
            padding: 16px;
            font-size: 16px;
            border: none;
        }

Corrected (View the snippet in full page).

I suggest removing inline CSS (the style attributes in your HTML elements) and transferring them to your CSS file to avoid confusion.

    html {
            height: 100%;
        }

        #box {
            height: 18.52vh;
            width: 72.92vw;
            background: #ffffff1a;
            display: flex;
            align-items: center;
            justify-content: center;
            border: thick solid red;
        }

        body {
            background-image: linear-gradient(#000000, rgb(119, 0, 0));
        }

        .container {
            margin: 0;
            position: absolute;
            top: 50%;
            left: 50%;
            -ms-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
        }

        .center {
            margin: 0;
            position: absolute;
            top: 50%;
            left: 50%;
            -ms-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
        }

        #butt {
            background-color: #9c0101a8;
            color: rgb(211, 211, 211);
            padding: 16px;
...

</body>

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

Generating PDFs with multiple pages using android.graphics.pdf

Currently, I am facing an issue while attempting to generate a PDF using android.graphics.pdf. The problem arises when dealing with multiple pages in the document. While I can provide android.graphics.pdf with HTML content that could be converted into a PD ...

The height percentage is not functioning properly even though it has been applied to the html, body, and all wrapper elements

I've been facing a persistent challenge with the height:100% problem. It seems like it should be an easy fix by ensuring all wrapper elements and html, body have height:100%, but no matter what I try, the containers still won't reach the bottom o ...

Tips for resolving browser compatibility issues

Recently, I built a website for my own purposes using Mozilla Firefox. However, when I switched over to IE7, the entire site seemed to disappear. All the structure and alignments were completely thrown off. Can anyone offer suggestions to help me resolve ...

The Vue.js modal is unable to resize below the width of its containing element

My challenge is to implement the Vue.js modal example in a larger size. I adjusted the "modal-container" class to be 500px wide, with 30px padding and a max-width of 80%. However, I'm facing an issue where the "modal-mask" class, containing the contai ...

Z-Index Problem with PureCSS Horizontal Scrollable Menu

I've been working on this issue but can't seem to get it right. I have a purecss menu with a horizontal scrollable feature, but the submenus at depth 1 and 2 don't appear on hover in Firefox and Safari - they are being hidden underneath. I ...

Troubles with the sliding feature on Bootstrap 4 Carousel

I'm encountering an issue with the bootstrap carousel as it's not sliding properly. Here is my current code: <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> ...

Concealing a message within a section that has been minimized to a width of 0

Recently, I've encountered a challenge in attempting to set the width of a section to 0 and have all its contents also disappear. Despite changing the section's width to 0px, the text inside continues to be displayed and even shifts off to the si ...

When a row is selected in Angular UI-Grid, copy the data from that row onto the clipboard

In need of a function to copy an entire row's data to the clipboard with a simple click. I have a Plunker link where I can only copy cell text: http://plnkr.co/edit/EVrB5Ib9ZuqhbAMsV9Eg?p=preview Below is the pseudocode for the Grid Options: $scope ...

What could be causing the `daterange` to display an incorrect date?

While developing my ASP MVC application, I implemented a daterange picker which worked perfectly. However, when I moved the application to production on IIS, the daterange stopped working and displayed an "invalid date" error. https://i.sstatic.net/J6Ylf. ...

Searching on the search bar using Django's object.filter method results in returning Object (1)

Recently, I have been working on a Django website Project that features a database filled with various books. Within the site, there is a search bar that allows users to type in the name of a book and receive results from the database. However, I have enco ...

What is the best way to create a form with two inputs that redirects me to a different page based on the inputs chosen?

Seeking assistance to resolve a challenging problem that I am currently facing. Any suggestions on the technology or backend skills needed for this task would be greatly appreciated, as well as any advice that can help me progress in the right direction. ...

Navbar not responding correctly to Bootstrap5 scrollspy feature

I'm currently working on implementing a scrollspy feature using Bootstrap 5.3. I've been referring to the Bootstrap 5 example to create my HTML page, which you can view at the following link: https://stackblitz.com/edit/web-platform-phnijx?file= ...

How to Conceal File Extensions with .htaccess

Can anyone provide guidance on the best way to hide .php extensions using HTAccess, even for sub-folders? I have attempted various solutions from previous answers but none seem to work. ...

Is there a method to imitate the background-size "cover" attribute specifically for a div nested within another div using CSS?

Is there a way to have a div inside a div behave like an image with the CSS property background-size:cover? I can't use the image as a background, so I'm looking for a solution that mimics the same behavior. ...

The loading of the Bootstrap tagsinput has encountered an error

I am facing an issue with my Django application where tags are not loading properly in an input field using jquery. It seems like the application is unable to locate the bootstrap-tagsinput.css and bootstrap-tagsinput.js files. Can anyone provide guidance ...

What is the best way to eliminate the left padding on a TimelineItem component?

When using the Timeline component to display information, there are three columns: TimelinItem, TimelineSeparator, and TimelineContent. I tried setting the padding of TimelineItem to 0 but it didn't work. The <Trace/> component is a sub-compone ...

Display of CSS triangle placed at the lowermost part of the webpage

When hovering over each item, I want a triangle to appear underneath it. Currently, the triangle is displaying correctly, but there's also an extra triangle showing up at the bottom. I'm not sure why this is happening and I can't figure out ...

The performance of my Wordpress site is being hindered by the slowdown caused by Admin

I have a Wordpress website focused on winter sports vacations in Iceland: link Every plugin, WordPress core, and theme are up to date. Using Woocommerce for my online store. However, activating the Woocommerce plugin causes the site to slow down signific ...

Is it possible for me to customize the functionality of a bootswatch theme?

I have implemented the Bootswatch Lux theme on my website built with Django. However, I have noticed that bold text seems to blend in too closely with regular text. Would it be advisable or feasible to modify the CSS in order to create a more noticeable d ...

Limit a user from inputting certain characters into a textbox

Is there a way to prevent a specific character from being typed into a text box? ...