The appearance of Bootstrap buttons is altered when they exceed the container width and a scrollbar appears

In my Bootstrap-designed page, I am utilizing a scrollbar to handle the overflow of elements. However, I've noticed that the rounded corners of my styled buttons disappear when the page overflows, resulting in plain rectangular buttons. Is this an inherent issue with overflow-y: scroll, or is there a way to prevent this from happening? Here is a snippet of my HTML:

    <div class="container px-4 px-lg-5 d-flex h-100 align-items-center justify-content-center">
        <div class="d-flex justify-content-center">
            <div class="text-center">
                <h6 class="text-white-50 mb-2 mx-auto">Your Ordered Playlist:</h6>
                
                <div class="scrol">
                {%for i in rankings%}
                    <div class="row">
                    
                <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist"/>
                    </div>
                {%endfor%}
                
                </div>
            </div>

        </div>
    </div>

And here is the relevant CSS:

.scrol {
   height: 400px;
   overflow-y: scroll;
 }

 .align-items-center {
   align-items: center !important;
}

.justify-content-center {
  justify-content: center !important;
}

/* Button Styling */
.btn {
    /* Button custom properties */
}

.btn-primary {
    /* Primary button custom properties */
}

I have experimented with button width adjustments and various overflow methods. While removing the scrollbar makes the buttons appear normal, it occupies too much space on the page, so that is not a feasible solution. Any advice on how to maintain the rounded corners of the buttons even in overflow situations would be greatly appreciated.

Answer №1

The styling for the button radius is present but not visible due to negative margins on the row class. To address this, add the container class to the scrol container to offset the negative margins and ensure proper visibility. It is important that the row class is nested within a container. Additionally, consider using overflow-y: auto.

<div class="container scrol">
    <div class="row">

original code:

<div class="container scrol">
    {%for i in rankings%}
        <div class="row">
            <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist"/>
        </div>
    {%endfor%}

Note: place content inside col to prevent style conflicts.

Alternatively, remove the row class from the children of the scrol container, move it to a parent container (e.g. the one following container), and utilize col for breakpoints:

<div class="container px-4 px-lg-5 d-flex h-100 align-items-center justify-content-center">
    <div class="row d-flex justify-content-center">
        <div class="text-center">
            <h6 class="text-white-50 mb-2 mx-auto">Your Ordered Playlist:</h6>
            <div class="scrol">
                <div class="">

docs:

Rows contain columns. Columns have horizontal padding (gutter) for spacing. Rows have negative margins to align column content.

Grid system

demo (add container to scrol):

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3/dist/js/bootstrap.bundle.min.js"></script>


<style>
  .scrol {
    height: 400px;
    overflow-y: auto;  
  }
  
  .align-items-center {
    align-items: center !important;
  }
  
  .justify-content-center {
    justify-content: center !important;
  }

   /* Additional button styling */
   .btn {
    --bs-btn-padding-x: 0.75rem;
    --bs-btn-padding-y: 0.375rem;
    ...
   }

   .btn-primary {
    ...
   }
</style>





<div class="container px-4 px-lg-5 d-flex h-100 align-items-center justify-content-center">
  <div class="d-flex justify-content-center">
    <div class="text-center">
      <h6 class="text-white-50 mb-2 mx-auto">Your Ordered Playlist:</h6>

      <div class="container scrol">

        <div class="row">

          <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist" />
        </div>

        <div class="row">

          <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist" />
        </div>

        <div class="row">

          <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist" />
        </div>

        <div class="row">

          <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist" />
        </div>
        <div class="row">

          <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist" />
        </div>

        <div class="row">

          <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist" />
        </div>

        <div class="row">

          <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist" />
        </div>

        <div class="row">

          <input autocomplete="off" value="{{i}}" class="btn btn-primary mt-3 text-wrap" name="playlist" />
        </div>
      </div>
    </div>

  </div>
</div>

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

What is the best way to insert a Bootstrap Glyphicon into an asp:TextBox within ASP.Net Webforms?

Can a Glyphicon be displayed in an <asp:TextBox> control? I attempted the following: <div class="col-md-10 has-feedback"> <asp:TextBox runat="server" ID="txtFullName" CssClass="form-control" MaxLength="50" /> <i class="glyph ...

Focused input filter in a tabular header style

I've been working on customizing the Tabulator header filter to have a more "flattened" style, as requested by my boss. In my CSS, I added the code ...input:focus{border:1px solid #1bb394} to change the input border to 1px green. While this change tak ...

jquery toggle for partial visibility not functioning properly

Can jquery sliding functions be used to partially show and hide content? In this scenario, there is a list with 7 items but only the first two are visible initially, while the rest are hidden. The goal is to have all 7 items show when the user clicks to v ...

Pondering in AngularJS - what is the best way to alter the DOM during an AJAX call?

I'm completely new to AngularJS and trying to transition from a jQuery background. After reading through "Thinking in AngularJS if I have a jQuery background?" on Stack Overflow, I understand the concept but am struggling to implement it without depen ...

Can a Dashcode Webkit Web app be transformed into traditional HTML and CSS?

I have developed a blog using Dashcode, incorporating HTML, CSS, and Javascript to pull data from an xml file. It's pretty simple... My perspective on this is: 1. JavaScript should be compatible with all browsers (with some variations). 2. I may need ...

Certain Bootstrap 5 icons are failing to appear on the screen

I'm encountering an issue with Bootstrap 5 where certain icons are not displaying correctly. The bi-search icon shows up perfectly, but the bi-send icon is not being shown at all. I would usually include this in a code snippet, but it seems that featu ...

Adjust the size of the HTML input font to decrease as additional text is entered

Is it possible to create an HTML text field that automatically adjusts the font size when the user types more characters than it can display? I know Acrobat has this feature for forms, but I'm looking to implement it in HTML. So, imagine having a te ...

Incorporate a JSON file into the Webpack output separately from the bundle.js file

Is there a way for my webpack application to read a JSON file at runtime without including it in the bundle.js after packaging? I want the JSON file to be available in the package folder but not bundled with the rest of the code. How can I achieve this? ...

When using NextJs, running the commands 'npm build' and 'npm start' can sometimes cause style inconsistencies

Currently working on a project with NextJs (sorry, no screenshots allowed). Running 'npm run dev' for development works perfectly fine, but when I switch to 'npm run build' and then 'npm start', the website displays overlappin ...

The issue of the selection option not being cleared after being set to 0 persists in JavaScript

I am facing an issue where I need to reset the select option to `0` when another option is selected. I have tried the code below for this purpose. if (varALPO1MobNum == "0") { var selectElement = $(&apo ...

Creating an interactive button using RichFaces and Bootstrap for seamless Ajax functionality

I have a challenge with making a fully clickable span or button that includes a Bootstrap refresh glyph-icon. The current code I have inherited only allows the icon itself to be clicked, leaving the area between the icon and button border unclickable. This ...

Using Bootstrap 4, create a responsive design that centers images within a div on mobile devices and positions them differently

I am currently working on a DIV that contains social media buttons. The code for this DIV is as follows: <div class="redes-sociales col-sm-pull-6 col-md-6 col-lg-push-4 float-right py-2"> <img class="img-rounded img-social" alt="f ...

CSS animation is activated solely upon its initial creation

Exploring the world of Vuejs for the first time with my debut project. The core of my project lies in the main component where I have an array as a data variable. Here's an example snippet: export default { name: 'example-component', ...

Having trouble with jQuery loading for the first time

I am having trouble getting the jQuery to load properly. My goal is to toggle classes on specific items identified by their ID. When an item is clicked, I want it to have the class "menu-selected" while the other item has the class "unselected." I have i ...

Challenges arise when trying to load CSS on an EJS page in conjunction with using res.redirect()

When using Express with EJS, my base route is set as follows: router.get("/", productsData.getProducts); The "productsData" is sourced from my controllers page and the code snippet within that page is as follows: exports.getProducts = (req, res, next) => ...

Looking to automatically dismiss a tooltip on mobile devices a few seconds after it's tapped

Here's an anchor tag with a tooltip: <a data-toggle="tooltip" data-original-title="Apologies, pronunciation audio is currently unavailable."> <span class="glyphicon glyphicon-volume-off pronounce"> </span> </a> When v ...

Revamp the sequence of divs using jQuery

<div class="example first">111</div> <div class="example second">222</div> <div class="example third">333</div> Can the order of these divs be changed using jQuery? I am looking to get: <div class="example second"&g ...

Covering a secret link with a backdrop image

I have set a background image in a column on my WordPress site. However, I want to make this image clickable by placing a transparent box over it, as background images cannot be linked directly. #container { background-image: url(https://www.quanser.c ...

Display only alphabetic characters in the text field

I have a jQuery function that I am working on: $('#contact_name').on('input', function() { var input=$(this); var re =/^[A-Za-z]+$/; var is_email=re.test(input.val()); if(is_email) { } else { } }); This function is targeted at the fol ...

Error message: "Azure deployment encounters Vue CSS dependency missing issue"

I recently built a Vue app following this tutorial but without CRUD functionality: . The app was created using Vue CLI 4.3.1 with vue create. During local development, it runs smoothly with npm run serve and builds without any errors. Now, I'm atte ...