The Bootstrap div is struggling to maintain its width on smaller screens

My attempt to create 3 inputs with the following code:

<div class="col-sm-5 col-md-6">
    <form>
      <div class="form-row">
        <div class="col-0.5 search-label">
          <label class="control-label">Search :</label>
        </div>
        <div class="col">
          <input type="text" v-model="company_name" @keyup="userFilterGlobal" class="form-control" placeholder="Company">
        </div>
        <div class="col">
          <input type="text" v-model="fullname" @keyup="userFilterGlobal" class="form-control" placeholder="Fullname">
        </div>
        <div class="col">
          <input type="text" v-model="email" @keyup="userFilterGlobal" class="form-control" placeholder="Email">
        </div>
      </div>
    </form>
  </div>

While this setup functions properly, it breaks at different resolutions like shown in https://i.sstatic.net/lI4iO.png.

It remains consistent until a smaller screen causes the input fields to enlarge as seen in https://i.sstatic.net/B4kaY.png.

Is there a way to ensure the input sizes remain the same as pictured when the screen size decreases from the first image?

Test out the code on CodePen: https://codepen.io/anon/pen/oRYZBx

Answer №1

To enhance your design, just insert

<div class="col-2 col-xs-2 col-sm-2 col-md-2">

into your div elements and adjust the "2" to fit the desired size based on the screen dimensions.

Explore this Codepen for a visual demonstration.

For more in-depth information on utilizing the bootstrap grid system, visit their webpage.

Answer №2

Responsiveness on the screen plays a key role in determining the layout. Please review the code snippet below for reference:


         <div class="col-sm-12 col-md-12 col-lg-12 col-xl-12">
    <form>
      <div class="form-row">
        <div class="col-0.5 search-label">
          <label class="control-label">Search :</label>
        </div>
        <div class="col-sm-4 col-md-3 col-lg-3 col-xl-3">
          <input type="text" v-model="company_name" @keyup="userFilterGlobal" class="form-control" placeholder="Company">
        </div>
        <div class="col-sm-4 col-md-3 col-lg-3 col-xl-3">
          <input type="text" v-model="fullname" @keyup="userFilterGlobal" class="form-control" placeholder="Fullname">
        </div>
        <div class="col-sm-4 col-md-3 col-lg-3 col-xl-3">
          <input type="text" v-model="email" @keyup="userFilterGlobal" class="form-control" placeholder="Email">
        </div>
      </div>
    </form>
  </div>

Answer №3

To effectively organize the elements on your webpage based on screen size, utilize the bootstrap grid system. For further information and guidance on using this grid system, click on the link below: Explore the link for more details

Answer №4

The col-sm has a minimum width set to 576px, which will not affect screen widths less than that.

If you want the col to always be a minimum of 5 units wide, you can use col-5 directly in Bootstrap 4 like this:

<div class="container">
  <div class="row">
    <form class="col-5 col-md-6">
      <div class="form-group row">
        <label class="col-form-label">Search :</label>
        <div class="col">
          <div class="form-row">
            <div class="col">
              <input type="text" v-model="company_name" @keyup="userFilterGlobal" class="form-control" placeholder="Company">
            </div>
            <div class="col">
              <input type="text" v-model="fullname" @keyup="userFilterGlobal" class="form-control" placeholder="Fullname">
            </div>
            <div class="col">
              <input type="text" v-model="email" @keyup="userFilterGlobal" class="form-control" placeholder="Email">
            </div>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>

Make sure not to skip the container and row levels of Bootstrap when using the col directly. You can choose between .container or .container-fluid based on your needs.

Failure to follow this structure may lead to padding, margin, or float issues as your layout becomes more complex.

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

Transitioning hover effects with absolutely positioned elements

I am facing an issue where I have an image with a centered absolutely positioned link on top of it. When I hover over the image, there are transition effects in place which work perfectly fine. However, when I hover over the link, these transition effects ...

What are some ways I can safeguard my CSS from injected elements?

I have created an HTML widget that is inserted into various websites without the use of iframes. However, I am encountering issues where the CSS of some sites is affecting the appearance of my elements, such as text alignment, underlining, and spacing. Is ...

Choose the correct checkbox among several options

On my webpage, I am facing an issue with checkboxes. No matter which checkbox I click on, only the first one is getting checked. I can't figure out what the problem is. Initially, the checkboxes weren't showing as checked, but now only the first ...

Unable to view Bootstrap modal upon click

Whenever I attempt to display a modal using Bootstrap, it mysteriously appears upon page refresh but fails to show up when the button is clicked. Ideally, I want the modal to only appear when the user clicks on the button. The structure of my html file lo ...

Creating dynamic PDFs with automatically adjusting heights in DOMPDF Learn how to make

It seems like this question may not have a straightforward answer, but let's give it a shot. My goal is to collect various information from users on my website and display it in an HTML template file that will later be converted into a PDF. With user ...

Add a CSS class to a different element when hovering

I have the following HTML structure: <div class="container"> <div class="list-wrapper"> <ul> <li class="item-first"> </li> </ul> </div> <div class="description-wrapper"> <d ...

What is causing the discrepancy in CSS line-height when text spans multiple lines?

Can anyone explain why there is extra space above the first paragraph in this HTML and CSS code, but not the second or third? The line-height is consistent for all three paragraphs. How can I adjust it so that there is equal spacing around all three paragr ...

Can a search engine algorithm be developed to display an iframe based on the keywords entered in the search query?

Is it possible to create a search engine algorithm in HTML, CSS, and JavaScript that takes keywords from a search bar input and displays the best solution (or solutions) through iframes? html, css, javascript Below is the code for the iframes and search ...

The button is only partially visible

My HTML code for a small web app has a button that says "ok," but it's too tiny to display the text fully. I wonder if I'm missing something with the span element? How can I enlarge the button so that it's bigger and shows the entire "ok" ...

Cross-platform mobile browsers typically have scrollbars in their scrollable divs

I have successfully implemented scrollable div's on a page designed for tablets running Android 3.2+, BlackBerry Playbook, and iOS5+ (except iPad 1). However, I would like to add scrollbars to improve the user experience. For iOS5, I can use the suppo ...

100% width with a pixel offset

In the past, I have achieved this by using padding. The concept is to have two div elements positioned side by side, where one has a width of 100% and the other has a fixed width of 50px. Here's a rough illustration: ------------------------------- ...

Adding CSS stylesheets on-the-fly in JavaFX

I am looking to incorporate a CSS file from the filesystem into my application. The goal is to allow users to dynamically add JavaFX CSS files that can be created by anyone and stored anywhere on their system. I attempted a test scenario to see if adding ...

"Adding jQuery functionality: displaying images in a popup on the same

Greetings to everyone here, it's my first time posting but I've been following some posts from time to time. So, hello all! I have a quick question that I haven't been able to find the answer for online. I'm dismantling a template to u ...

Avoid showing an image when it is outside the div container

Within a single div, I have an assortment of images that are dynamically repositioned using JQuery. $("#"+carElem).css({"left": pos.left+50 +"px"}); I am currently utilizing absolute positioning (although relative positioning yields the same outcome). Is ...

What is the best method for incorporating a unique style to a v-dialog component in Vuetify following the most recent update?

I'm currently working on a project using vuetify, and I am facing an issue while trying to add a custom class to a v-dialog component. I have tried searching for information on how to do this, but it seems that the prop "content-class" has been deprec ...

Incorrect CSS percentage calculations detected on mobile devices

My webpage consists of three large containers, each with an alpha transparent background. While they display correctly on desktop browsers, I'm facing alignment issues on tablets (both iOS and Android) and iPhones where the percentage sum seems to be ...

Menu Tabs with Rounded Edges

Seeking help to round the corners of a tabbed dynamic menu using Drupal and the dynamic-persistent-menu module. The code provided below is almost perfect, with 99% accuracy. View the current state of the menu here: . Can anyone assist in achieving the rema ...

Is it possible for Carousel to showcase a different layout other than tables or items? And is there a way to customize

I'm trying to use Bootstrap 5 to display items in a row, like sets of 3 or 12, and have them slide into view one set at a time. However, when I add a carousel, the items end up stacked on top of each other. Here is the code snippet: <div c ...

Tips for incorporating a background color into a specific section

Code: .headline { font: 150 50px/0.8 'Pacifico', Helvetica, sans-serif; color: #2b2b2b; text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1), 7px 7px 0px rgba(0, 0, 0, 0.05); text-align: center; } <link href='http://fonts.googleapis.com ...

Can Javascript be used to identify the number of td elements in a table and specify column widths within the table tags?

Is there a way to automatically add the "col width" tag based on the number of td tags within a Table tag? For example, if there are 2 td's, then it should add 2 "col width", and if there are 3 then, 3 "col width", and so on. <!DOCTYPE html> &l ...