Restrict button size in Bootstrap 4, Adjust margin between div elements

First and foremost, I do not want to alter the responsive design. I have 3 questions and appreciate your help.

  1. I am looking for a button with 2 lines of text. The first line should read "XXX Pump" and the second line should be "P01," and these lines should not overlap.

  2. When a very long text is inputted, the button size becomes larger than normal (see the 5th button).

  3. The spacing between the buttons is excessive. I tried creating a div for each button for better responsive design but couldn't reduce the space.

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no>

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous>

    <link rel="stylesheet" type="text/css" href="index.css>

    <title>S7-1200 WEB SERVER</title>
  </head>
  <body>


<nav class="navbar navbar-expand-lg navbar-dark bg-dark>
<div class="container>
  <a class="navbar-brand" href="#">Test</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation>
    <span class ="navbar-toggler-icon></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent>
    <ul class="navbar-nav mr-auto>
      <li class="nav-item active<
        <a class="nav-link" href="#">Manual Control <span class="sr-only">(current)</span></a>
      </li>
    </ ul>
  </div>
  </div>
</nav>


<div class="container>
  <div class="row>
    <div class="col-lg-2>
      <div class="col-lg-12>
        <div class="hero-button text-center>
          <a href="#" class="btn btn-large btn-danger>
            <span style="font-size:smaller><Pre Heating Pump</span><
              PU01
          </a>
        </div>
      </div>
    </div>
    // Repeat above section as needed...
  </div>
</div>



    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymou</script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymou</script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymou</script>
  </body>
</html>

Answer №1

When tackling the 1st question, consider utilizing the .d-block class found in the display utilities of Bootstrap as a substitute for using <br> for line breaks.

Here's an example:

<a class="btn btn-primary">
  <span class="d-block">Pre Heating Pump</span>
  <span class="d-block">PU01</span>
</a>

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

Bug with IOS double tap on Element UI VueJS select input element

Encountering a strange problem on iOS safari or chrome. When attempting to select an option from a dropdown input, the options show up correctly on the first tap, but when trying to actually select an option, it requires two taps to work properly. This is ...

The functionality of AngularJS ng-click is disrupted by the presence of {{$index}}

Having an issue with AngularJS where using $index breaks the ng-click function. This issue arises within a div utilizing ng-repeat, the repeat code is functioning correctly... <a class="accordion-toggle" data-toggle="collapse" data-parent="#acc{{$inde ...

Transferring an object from one inventory to another

I'm in the process of developing a task manager that enables users to add and remove tasks. I am also working on enabling the ability for users to transfer tasks from one list to another. The current code I have written doesn't seem to be functio ...

Align the content of a collapsed bootstrap row vertically

In a row, I have two columns, each containing their own row. When the page width hits the 'xs' break-point, the left column's row will stack its columns on top of each other. The right column is taller than the left column, which leaves a l ...

Uninterrupted Horizontal Text Scrolling using Pure CSS

I am currently working on developing a news ticker that displays horizontal text in a continuous scrolling manner, without any breaks between loops. While I hope to achieve this using only CSS and HTML, I'm unsure if it's feasible. Here is my ini ...

I am having trouble accessing the div. What could be causing this issue?

Here is the code I have written: - <html> <head> <title>Pranav Sharma</title> <style> @import url(http://fonts.googleapis.com/css?family=Lato:300,400,700); body { background: #ecf0f1; font-fami ...

Updating the appearance of a non-declared HTML child component on-the-fly using Angular

Trying to dynamically adjust the style of an unspecified div is causing some trouble. Using Angular and PrimeNG, invisible divs are being generated that I cannot access through inline styles. The objective is to allow a user to input a width as a string (5 ...

Issue with displaying Favicon on staging server

I need assistance with this issue. I am working to show a title and logo on a tab. It is functioning correctly on my local machine, but the logo is not appearing on the staging server. <title>Global</title> <link type="image/png" href ...

3-Column Layout with Left-Floated Columns Displaying Incorrect Order

Currently, I am in the process of converting a 3-column website to be responsive by using percentages and em's instead of negative pixel margins. This will ensure that the site functions well on various devices. I am facing a similar issue as discuss ...

Is there a way to make a sass file universally accessible without having to import it into every file and causing an increase in bundle size?

Question How can I efficiently import variables.scss globally without the need to duplicate them in every file and reference them in my build instead of importing? Setup I am using Vue2 with laravel-mix, where I have imported index.scss in my main.js ...

Can someone provide guidance on styling bidirectional text within a tooltip using bootstrap 4?

Is there a way to make Bootstrap tooltips display a mix of left-to-right and right-to-left languages, with the main direction being right-to-left? For example, I want the tooltip content to appear as "كلمة1 Word2 كلمة3 Word4 كلمة5", where the w ...

"Div vanishes mysteriously while CSS transition is in progress

When I have two divs positioned alongside each other, and one collapses to the left upon clicking a button, the remaining div on the right fills the available space due to its width being set at 100%. However, during the collapsing transition, the right di ...

Transform Java code into HTML format for a visually appealing display similar to that in an Integrated Development Environment

Is there a way to showcase my Java code on an HTML page to resemble an Integrated Development Environment (IDE)? I've been searching for existing solutions but haven't found anything satisfactory yet. Ideally, I am looking for something similar t ...

I am experiencing difficulties with my HTML and CSS code not functioning as I had initially intended

I've been dabbling in HTML and attempting to create my own website, but I'm encountering an issue with the positioning of my <table> tag. It keeps appearing at the bottom of the site, despite my CSS instructions to prevent it. The position ...

Exploring Palindromes with AngularJS

I'm trying to create an angular app that checks for palindromes, but it's not working and I can't figure out why. Can someone help me spot the mistake? http://plnkr.co/edit/EmOGhR?p=preview $scope.CheckForPalindrome = function() { ...

css styles for URLs that are sensitive to letter case

I'm currently at a loss for solutions as I can't seem to pinpoint the reason behind this peculiar behavior. I'm using Orchard CMS 1.4 along with a customized superfish stylesheet. Interestingly, the behavior varies depending on how the site ...

``I am experiencing an issue where Bootstrap fails to load when my HTML files are stored within

My first web app using Spring and Thymeleaf hit a snag when I stored my HTML files in the "templates" folder as required by Thymeleaf. Suddenly, my bootstrap, JS, CSS, and other resources stopped working. Despite moving the CDN links to the header and tryi ...

Position the center button on the Bootstrap navbar while keeping it outside the collapse menu

I want a button in the navbar that: stays inline with other navbar items (doesn't go to the next line); sits outside of the collapsed navbar section; and remains centered on the page for all screen sizes, even when the right side of the navbar is c ...

Using jQuery, you can apply a class to an element and then have it removed automatically after

Is there a way to add a class and then remove it after 500 milliseconds using jQuery? I tried using delay() but it didn't work as expected. Here is a simple example where I am changing the background color: Check out this code pen jQuery $('.b ...

Can you explain the distinction between div and span tags?

HTML includes two main tags, div and span. I am curious about the specific functions and roles of each tag. I have experimented with both but haven't been able to identify any significant differences. Can someone provide a detailed explanation on the ...