Overlap of text boxes in Bootstrap login form

I have tried looking at other solutions for this issue but none have worked for me. I am really confused by this problem.

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

The border on the right side is overlapping. Here is my CSS for the box:

input[type=text], input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}

I attempted using max-width: 100%; but it did not make a difference.

Here is the code for the form:

form {
border: 3px solid #f1f1f1;
}

input[type=text], input[type=password] {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  box-sizing: border-box;
}

button {
  background-color: #4CAF50;
  color: white;
  padding: 14px 20px;
  margin: 8px 0;
  border: none;
  cursor: pointer;
  width: 100%;
}

button:hover {
  opacity: 0.8;
}

.cancelbtn {
  width: auto;
  padding: 10px 18px;
  background-color: #f44336;
}

.imgcontainer {
  text-align: center;
  margin: 24px 0 12px 0;
}


img.avatar {
  width: 40%;
  border-radius: 50%;
}

.container {
  padding: 16px;
}

span.psw {
  float: right;
  padding-top: 16px;
}

/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
  span.psw {
     display: block;
     float: none;
  }
  .cancelbtn {
     width: 100%;
  }
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <h2>Login To Your Account</h2>
  <form action="/action_page.php">
    <div class="imgcontainer">
      <img src="img_avatar2.png" alt="Avatar" class="avatar">
    </div>
    
    <div class="container">
      <label><b>Username</b></label>
      <input type="text" placeholder="Enter Username" name="uname" required>

      <label><b>Password</b></label>
      <input type="password" placeholder="Enter Password" name="psw" required>

      <button type="submit">Login</button>
      <input type="checkbox" checked="checked"> Remember me
    </div>

    <div class="container" style="background-color:#f1f1f1">
      <button type="button" class="cancelbtn">Cancel</button>
      <span class="psw">Forgot <a href="#">password?</a></span>
    </div>
  </form>
</div>

Answer №1

One possible solution would be to assign a specific width to the container element.

.container {
    width: 100%;
    padding: 16px;
}

This adjustment could potentially resolve the issue at hand.

If that does not work, another approach could involve setting a narrower width for the input textboxes:

input[type=text], input[type=password] {
width: 75%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}

While using !important is generally discouraged, you might consider applying it to the width property as a last resort:

input[type=text], input[type=password] {
width: 75%!important;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}

Furthermore, it appears that the login button is overlapping. In this case, the same width: 75%; rule should also be added to the submit input. However, without visibility of your submit input class, I cannot provide specific instructions on how to address this issue.

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 size of Bootstrap 3 columns adjusts dynamically based on the width of the window as the page is being

I am facing an issue with the layout of my bootstrap site when resizing the 3 horizontal columns based on the window size upon page load. Currently, I have a script that adjusts the height of each column to match the tallest one so they appear uniform whe ...

Troubleshooting a problem with media queries causing display:none issues

Check out this HTML email template code we've been testing on various email clients including Gmail, Yahoo, Outlook, Rediffmail, iPhone, and iPad. The template consists of two table blocks - one for web browsers and the other for mobile devices like ...

Using jQuery to toggle CSS properties

I'm having trouble switching between a CSS column layout and a normal layout for a div element with the ID 'article'. The jQuery script I wrote doesn't seem to work properly, as the entire thing disappears. Can anyone advise me on how t ...

What could be causing the CSS to not apply in my React component?

Why isn't the css from main.css file working properly in Main.js file? //Below is the code snippet from Main.js-- View Main.js screenshot View main.css screenshot View website screenshot View folder structure screenshot I am attempting to create ...

What is the most effective method for declaring a constant within a WebComponent?

After receiving questions, I included more details on how I'm utilizing the constants. The main issue I am encountering is that the constants are being added to the global object, which raises concerns about potential name collisions. I created a Web ...

Executing Python output in HTML with Django

I am currently working on a Django project and in the views.py file of my app, I have some outputs stored in a dictionary. The code snippet from views.py is as follows: from django.shortcuts import render def allblogs(request): a = request.GET[' ...

"Exploring the Differing Approaches of Ajax: Constructing

Considering StackOverflow's recommendation to ask a question rather than start a discussion, let's explore two methods using HTTPAsyncRquest to update a webpage without refreshing it: 1) Parsing/interpreting data returned by AsyncRequest to buil ...

Exploring jQuery Efficiency: Comparing CSS and Animation Techniques

I am trying to steer clear of using the animation property because it tends to be slower compared to CSS3 animations. My query is whether utilizing the css method is faster than the animation property, but still slower than a direct CSS3 animation with tr ...

Can anyone provide instructions on how to show or hide alerts in Bootstrap 5?

I have a snippet in my html file that looks like this: <div class="alert alert-success alert-dismissible"> <button type="button" class="btn-close" data-bs-dismiss="alert"></button> <strong> ...

How to properly align an HTML TD element with a Div nested inside

I am encountering a situation where I have a TD tag with align="right". Inside this TD tag, there is a div element with align="left". My goal is to: Align the contents of TD to the right (in this case, the DIV) However, align all the contents inside the ...

Looking to alter the appearance of a div within an iframe by matching it with the title of the parent window using javascript?

I am currently working on a parent page titled Criatweb, which contains an iframe page. My goal is to modify the display of a specific div within the iframe page only when its title matches Criatweb. I attempted to implement the following script within t ...

Mysterious purple squares mysteriously popping up around elements in a WordPress website utilizing CSS Bootstrap 4

While browsing certain websites on specific browsers that utilize Bootstrap 4 as a framework within a WordPress site, I've noticed some elements displaying strange purple squares when visited. Any ideas on the cause of this issue and how it can be res ...

The button I have controls two spans with distinct identifiers

When I press the player 1 button, it changes the score for both players. I also attempted to target p2display with querySelector("#p2Display"), but it seems to be recognized as a nodeList rather than an element. var p1button = document.querySelector("# ...

Unable to achieve desired result when trying to combine styled components props with next adjacent selector

After transitioning from active classes to passing props to styled components, I encountered a minor issue. The prop passing is functioning correctly, but there seems to be an issue with the CSS. Prior to switching to props, this section worked flawlessly ...

The CSS3 scale() function leads to div elements appearing grainy

After experimenting with CSS3 animations, I've noticed that using the scale() function seems to cause pixelation on every element it's applied to. For example, check out this demo: http://jsfiddle.net/PD7Vh/2/ In the provided link, you can see ...

How to center an image within a viewport without worrying about the width of the viewport

I'm working on centering an image slideshow within the viewport, regardless of its width. It's easy to accomplish when the viewport is wider than the image by using margin: auto;. However, when the viewport is narrower than the image, such as on ...

Content in the Bootstrap carousel vanishes without warning after a period of time

I am facing an issue with a carousel I added to a section of my website using HTML, CSS, and Bootstrap 5. The problem is that after some time, the content and the carousel inside that section disappear. Reloading the page temporarily fixes this issue but ...

How to set up a multi-select box for tagging purposes

I tried to implement a multi select box to create tags using the code below. I downloaded select2.min.css and select2.min.js from https://github.com/select2/select2, then copied them into the project's css and js folders. Here is the HTML code snippe ...

The reason for the lack of auto complete functionality in this specific Bootstrap example remains unclear

I've been attempting to implement an auto-complete dropdown feature with dynamic data, but I'm facing an issue where no suggestions are displayed in the dropdown. I found this example on Datalists: https://getbootstrap.com/docs/5.1/forms/form-con ...

Does anyone know of a markdown parser compatible with Jekyll that works well with mathjax?

I currently run a Jekyll-based blog and am in search of a markdown parser that doesn't disrupt my Mathjax expressions. In the past, I've encountered issues where the parser misinterprets equations involving subscripts and symbols. Interestingly, ...