Let's explore a way to make the button text wrap onto multiple lines for smaller screens when using Bootstrap 4.0

I am encountering an issue with the layout of my asp.net mvc core web application + bootstrap 4.0 FAQ section. The problem is that the question description overflows the screen on small screens, while the answer text aligns properly. I need a solution to make the button text span multiple lines on smaller screens. Here is the code snippet:

                     @foreach (var item2 in Model.OrderBy(a => a.Description))
                            {
                                <div class="card">
                                    <div class="card-header" id="@item2.Id+'headingTwoa'">
                                        <h5 class="mb-0">
                                            <button class="btn btn-link collapsed" data-toggle="collapse"
                                                    data-target="#@item2.Id" aria-expanded="false"
                                                    aria-controls="collapseTwo">
                                                @Html.DisplayFor(modelItem => item2.Description)
                                            </button>
                                        </h5>
                                    </div>
                                    <div id="@item2.Id" class="collapse" aria-labelledby="headingTwoa"
                                         data-parent="#accordion" style="">
                                        <div class="card-body">
                                            @Html.Raw(item2.Answer)
                                        </div>
                                    </div>
                                </div>
                            }

Edit-1:-

Check out the code for a question that spills over on small screens:

<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#1004" aria-expanded="false" aria-controls="collapseTwo">
What services are being provided?  What if my practice is already performing these services?
</button>
              

                      

Answer №1

I discovered a neat trick on Bootstrap's official website where text added to a button automatically spans multiple lines. To get a better understanding, screenshots of a webpage and HTML code are needed, preferably from the browser's "elements" tab rather than ASP.NET. It's possible that there's just a really long word causing the issue. For additional insights, check out this link: https://developer.mozilla.org/ru/docs/Web/CSS/word-break

Edit 1

I copied and pasted your button into the exact same component on the Bootstrap website (https://getbootstrap.com/docs/4.5/components/collapse/#accordion-example) and it still functions correctly. However, it's still challenging to provide a clear answer. As a suggestion, consider adding a btn-block class to your buttons. Additionally, sharing screenshots of your current setup and the computed props tab might help identify any custom settings that could be causing the issue. Here is a guide on how to access the computed props tab: . Select your button, switch to the computed tab, and share all the properties that the browser applies to your button.

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

Is there a way to use the same color picker tool for adjusting both the background and text colors simultaneously?

My goal is to create functionality where the user can change the background color by clicking on the background of the div, and change text color by clicking on the text within the div. var box1 = document.querySelectorAll('.color1'); var pic ...

Ways to conceal an item by considering the size of a different element

I have a question about displaying content within a div element. I want to show a "show more" button only if the content inside the div exceeds a max height of 530px. Otherwise, the button should remain hidden. Here is the code snippet I'm using: Ja ...

Effortlessly navigate between Formik Fields with automated tabbing

I have a component that validates a 4 digit phone code. It functions well and has a good appearance. However, I am struggling with the inability to autotab between numbers. Currently, I have to manually navigate to each input field and enter the number. Is ...

Text alignment and block dimensions

I attempted to organize three buttons within a block. <link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.0.3/tailwind.min.css" rel="stylesheet"/> <div class="grid grid-cols-1 md:grid-cols-3 text-center place-content-center"> ...

Transforming html designs into pdf files using wkhtmltopdf tool

While attempting to convert three HTML files (body template, header template, footer template) to PDF using wkhtmltopdf, I encountered an error stating "Unknown long argument --header-htmlá". This issue arose after a recent PC update, as everything was fu ...

help with coding in html and css

Hey there, I’m currently working on creating a loading page for my website, but I seem to be facing an issue with a white line appearing along the top and one running down the left side. If anyone could provide me with some assistance on this matter, I ...

Various lists do not appear directly under each other

Hello everyone, I recently created a webpage displaying different lists of football players. My goal is to keep the lists stacked vertically without any floats that would make them appear side by side. The separate lists are essential for properly categori ...

Position a button to be aligned with the bottom of its container

My goal is to have the button positioned at the bottom of the red div, nested inside it. .grand-parent { display: flex; flex-direction: row; flex-wrap: wrap; height: 300px; background-color: green; } .pa ...

Insert fixed text before or after the input value without altering the value itself

Is it possible to prepend or append additional text to an input value? I am looking to customize the display of a value without altering the actual value itself. For instance, if the value is 1000, I want it to still return 1000 when accessed. <input ...

When a div is floated to the right, it can lead to unexpected outcomes

Here is the code structure in the JSfiddle link below. When I apply float:right to the "Add" text, it creates extra space above the "Quick Links" & "Top 20 Sites" sections. #home-content { padding: 5px; } #home-content .css-table #row1-col3 .col-body { ...

Tips for creating a scrolling iFrame that moves with the background

I have recently created a website with a unique design feature. The background image acts as a border surrounding the main content, which is located within an iFrame. However, I've encountered an issue where scrolling the iFrame does not affect the ba ...

Using jQuery to dynamically update elements as the user scrolls

Looking to dynamically update the position of a div on a webpage as the user scrolls down? Check out this JavaScript script that utilizes a h2 HTML element to display the y-coordinate of the element. To see the script in action, visit the following jsFiddl ...

Oddly stacked masonry tiles in a horizontal layout

After spending more than an hour trying to figure it out, searching and reviewing other solutions, I still haven't been able to resolve my issue. My problem is with 5 divs, where the third and fourth div are not stacking up as expected. Instead, the ...

Next.js is causing me some trouble by adding an unnecessary top margin in my index.js file

I started a new project using next.js by running the command: yarn create next-app However, I noticed that all heading and paragraph tags in my code have default top margins in next.js. index.js import React, { Component } from "react"; import ...

Roundabout Navigation Styles with CSS and jQuery

My goal is to implement a corner circle menu, similar to the one shown in the image below: https://i.stack.imgur.com/zma5U.png This is what I have accomplished so far: $(".menu").click(function(){ $(".menu-items").fadeToggle(); }); html,body{ colo ...

When using Vue with CSS3, placing an absolute positioned element within a relative wrapper can cause issues with maintaining the

Just starting out with Vue and diving into the world of CSS3! I'm currently working on a component that you can check out here: https://codesandbox.io/s/yjp674ppxj In essence, I have a ul element with relative positioning, followed by a series of di ...

Techniques for animating background image using jQuery

Hello there! I'm currently experimenting with animating a background image using jQuery. Despite following a tutorial, I haven't been successful in getting my test page to work as intended. The blue Facebook icon displays, but it doesn't ani ...

Cascading Style Sheets displaying inconsistently between local environment and server

Is it just me or does anyone else experience CSS behaving differently on a remote EC2 server compared to a local server? When I load the page and inspect it, I notice that different CSS rules are being applied. I've already executed collectstatic and ...

Something seems to be preventing Div from appearing and there are no error messages appearing

I've been attempting to create a menu, but the toggle div for the menu isn't visible Following a tutorial where an individual sets up a menu, there is a div with a menu icon in the top left corner. Despite meticulously copying the code from the ...

Some of the picture remains concealed without spilling over

I've been struggling to get my logo to display properly on my website. I have managed to position it, but the image isn't fully visible. Here's a screenshot for reference: http://gyazo.com/1d23c924cdb401fc0cca76b946e57dcb There doesn't ...