The background for the Bootstrap Input doesn't extend to the full input area

After attempting to create a basic form page using Bootstrap, I encountered an issue with the background color. Instead of sticking with the default white background, I decided to override the "form-control" class's background color and use light gray instead.

However, this change resulted in part of the right side getting cut off unexpectedly. I suspect it has something to do with the background color adjustment, but I'm not sure. That's why I need help figuring it out!

Here is an image showing the problem:

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

Below is the code snippet that is causing the issue:

<link href="https://fonts.googleapis.com/css?family=Inconsolata:400,700%7CRaleway:400,700&display=swap"
    rel="stylesheet">
   
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<style>
.formKeepLeft {
    display: flex;
}

.skipLine {
    clear: left;
}

.form-control, .form-control:focus {
    width: 100%;
    border-radius: 0px;
    background-color: lightgray;
}

.skipLine {
    display: block;
}
</style>

<div class="row">
    <div class="col-6">
        <!--- Col 1 --->
        <form>
            <div class="formKeepLeft">
                <div class="form-group">
                    <label for="inputEmail">Namn</label>
                    <input type="input" class="form-control " size="100%" id="inputName" placeholder="">
                </div>

                <div class="form-group" style="padding-left: 10px;">
                    <label for="inputPassword">E-post</label>
                    <input type="email" class="form-control " size="100%" id="inputEmail" placeholder="">
                </div>
            </div>

            <!-- Form row 2 -->
            <div class="form-group skipLine">
                <label for="inputPassword">Ämne</label>
                <input type="input" class="form-control " size="100%" id="inputÄmne" placeholder="">
            </div>
        </form>
    </div>
</div>

<!-- JS files: jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

Upon resizing the page, the cutoff issue becomes more prominent. It seems to work fine for col-lg sizing, but misbehaves with other sizes. Attempting to tweak the background-size property didn't yield any positive results.

My goal is illustrated in this reference image:

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

The image showcases the desired outcome without any cut-off on the right side. If anyone has suggestions or solutions, I would greatly appreciate the help.

Thank you in advance for your support!

Answer №1

One way to fix the gap caused by border-radius is to use border-width: 0;.

<link href="https://fonts.googleapis.com/css?family=Inconsolata:400,700%7CRaleway:400,700&display=swap"
    rel="stylesheet">
   
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
       
<!-- JS files: jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<style>
.formKeepLeft {
    display: flex;
}

.skipLine {
    clear: left;
}

.form-control, .form-control:focus {
    width: 100%;
    border-radius: 0px;
    background-color: lightgray;
    border-width: 0;
}

.skipLine {
    display: block;
}
</style>

<div class="row">
    <div class="col-6">
        <!--- Col 1 --->
        <form>
            <div class="formKeepLeft">
                <div class="form-group">
                    <label for="inputEmail">Namn</label>
                    <input type="input" class="form-control " size="100%" id="inputName" placeholder="">
                </div>

                <div class="form-group" style="padding-left: 10px;">
                    <label for="inputPassword">E-post</label>
                    <input type="email" class="form-control " size="100%" id="inputEmail" placeholder="">
                </div>
            </div>

            <!-- Form row 2 -->
            <div class="form-group skipLine">
                <label for="inputPassword">Ämne</label>
                <input type="input" class="form-control " size="100%" id="inputÄmne" placeholder="">
            </div>

        </form>
    </div>
</div>

Answer №2

To create more space, consider adding border:0; to alter how the corners are displayed and potentially improve the appearance of the border.

.form-control, .form-control:focus {
 width: 100%;
 border-radius: 0px;
 background-color: lightgray;
 border: 0;
}

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

Tips for toggling CSS classes based on the user's current page

<nav id="navMenu" class="navMenu"> <ul> <li class="active homePage"> <a href="index.php" title="Homepage">Home</a> </li> <li class="resourcesPage"> <a href="re ...

Adjust image size while maintaining aspect ratio

Currently, I am implementing a resize function for an image by using the following code snippet: $('.image_resize').each(function(){ var ww = $(window).width() - 80 - 400; var wh = $(window).height() - 60; var iar = $(this).attr(&apo ...

Disable the div by graying it out when the button is clicked

In my jsni form, I have implemented a click handler on the save button. When the save button is clicked, I would like the specific div to be greyed out to indicate that data is being saved. var x=$doc.createElement("div"); x.id="nn"; var lbl=$doc.createEl ...

Updating a dynamic div with success using Jquery .ajax

I need assistance with updating dynamic divs on a page that contains multiple forms generated from a database. Each form has a unique div at the bottom with dynamic IDs like tempdiv_1, tempdiv_2, and so on. My goal is to use jQuery to update these divs ba ...

When the screen size changes, the centrally aligned position of sticky elements does not stay consistent

It has come to my attention that when centrally aligning an element with position sticky, the alignment can start to malfunction upon reducing the screen width past a certain point, depending on the width of the element. Unlike position: fixed, the sticky ...

Optimizing Spacing in Twitter Bootstrap 3.1 Nav-stacked Design

Being a novice in HTML coding, I decided to utilize an established API for my project. After some previous experience, I opted to use Twitter Bootstrap 3.1. Here is how my current nav-stacked section appears with a customized CSS to make it collapsible: ...

Animate the downward movement of the parent of a specific element, while simultaneously animating the upward motion of all others that are

When clicking a button, I am trying to slide down only the ul elements that are parents of the li.newlist element, while sliding up all the others. Although I have successfully managed to slide down the desired elements, I am unsure how to define the secon ...

Identifying a Resizable Div that Preserves its Aspect Ratio During Resizing

Below is the HTML code snippet I'm working with: <div id="myid_templates_editor_text_1" class="myid_templates_editor_element myid_templates_editor_text ui-resizable ui-draggable" style="width: 126.79999999999998px; height: 110px; position: absolut ...

A step-by-step guide to customizing the Material UI Chips delete SVG icon to appear in white color through

Using a Material UI component, I added a custom class to my chip. Attached is a screenshot showing what I mean. Currently, I am attempting to change the color of the cross button to white. After inspecting the element, I discovered that it is an SVG ico ...

Embedding a CSS class within the primary class selector

Can someone help me with this HTML challenge? <div class="span3"> <div class="abc">code for first div</div> <div class="abc">code for second div</div> </div> I'm trying to hide the first "abc" division within th ...

Here's how you can pull information from a MySQL database and showcase it on an HTML

I successfully created a database in MySQL where users can enter their details on /upload.html, which then get stored in the test2 database and person_list table. However, I am facing an issue with displaying this data on /download.html. My goal is to hav ...

Create a triangular shaped division element to contain text and automatically close when the user moves the cursor away

Is there a way to create a triangular div that can display text and images? I tried this method, but the issue I'm facing is that when the div opens on hover, it doesn't close properly when I hover out. Since the div is in a square shape, how ca ...

The iframe is not large enough to contain all the HTML content

I'm encountering a problem with a website I'm currently developing - specifically, I am struggling to embed an HTML document into an iframe in a manner that fills the entire page. Additionally, I am utilizing Angular to retrieve the HTML document ...

Resolved issue with header covering page content

https://i.sstatic.net/1PhFl.jpg The content underneath my fixed header is getting covered slightly by the header, rather than aligning perfectly with it. Ideally, the top of the carousel should be right below the bottom of the header to occupy the entire ...

Disappearing Bootstrap 3 Dropdown Issue Caused by Tab Click

There is an issue with the drop-down menu I created: When I click on tabs like ALL or FILM, it closes all elements. To reopen, I have to click again on the button PRODUCT.dropdown-toggle. The code example looks like this: var App = function () { ...

Mpdf does not support inline CSS rendering

I recently implemented Mpdf into my Symfony project using Composer. The installation process involved running the following command: composer require mpdf/mpdf Next, I included the Mpdf.php file in autoload.php. Here is an example of how to use Mpdf in ...

What steps can one take to successfully make the transition to the highest level?

I am currently working on implementing a transition effect in Vue.js. I want to create an animation where, upon clicking the search bar, it smoothly moves up to the top of the screen and simultaneously shrinks in size. App.vue <template class="t ...

Displaying PDF files on the internet without allowing them to be downloaded

How can I display PDF files on my website without allowing them to be saved or downloaded? Is there a way to prevent browsers from saving or downloading the PDF files? ...

Boost the dimensions of the content property within a CSS class

I am currently using the content property to display a dashed arrow "-->" in my CSS class. However, the arrow appears very small and I would like to increase its size directly in the CSS class itself. This arrow is meant to be displayed before each elem ...

Is it possible for a CSS Transition/Transform to ease out smoothly yet not ease in at all?

It appears that the transition is smoother when I stop hovering over the button, compared to when I actually hover. Why might this be? .button_1 { border-width: 0.8px; border-color: Lightgray; background-color: hsla(209, 72%, 59%, 0.85); ...