Maddie Graham
Maddie Graham

Reputation: 2177

Many badges move to the line below - Bootstrap

In my project I use Bootstrap badge to display the price list. My price list is moved to a new line and cut on mobile devices.

enter image description here

Mobile:

enter image description here

How to create a lot of badge so that only the last one is moved to the new line. I don't want to have them all in one line.

My code:

<p class="mt-0 mb-2 text-sm">
  <span class="mr-1">
    Talk time:
  </span>
  <span class="badge badge-white ml-1">
    <i class="fas fa-euro-sign"></i> {{ talk_1 }}/30min
  </span>
  <span class="badge badge-white ml-1">
    <i class="fas fa-euro-sign"></i> {{ talk_2 }}/1h
  </span>
  <span class="badge badge-white ml-1">
    <i class="fas fa-euro-sign"></i> {{ talk_3 }}/2h
  </span>
</p>

If I don't use badge but the text and icons itself. Everything is correctly transferred to new line and is not cut on mobile devices.

Upvotes: 0

Views: 749

Answers (1)

Mohit Kumar
Mohit Kumar

Reputation: 740

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
    <script src='https://kit.fontawesome.com/a076d05399.js'></script>
</head>
<body class="bg-dark">
    <div class="mt-0 mb-2 text-sm">
        <div class="mr-1 text-light">
          Talk time:
        </div>
        <span class="badge badge-light ml-1">
          <i class="fas fa-euro-sign"></i>  150/30min
        </span>
        <span class="badge badge-light ml-1">
          <i class="fas fa-euro-sign"></i>  200/1h
        </span>
        <span class="badge badge-light ml-1">
          <i class="fas fa-euro-sign"></i>  250/2h
        </span>
        <span class="badge badge-light ml-1">
            <i class="fas fa-euro-sign"></i>  250/2h
          </span>
          <span class="badge badge-light ml-1">
            <i class="fas fa-euro-sign"></i>  250/2h
          </span>
          <span class="badge badge-light ml-1">
            <i class="fas fa-euro-sign"></i>  250/2h
          </span>
          <span class="badge badge-light ml-1">
            <i class="fas fa-euro-sign"></i>  250/2h
          </span>
          <span class="badge badge-light ml-1">
            <i class="fas fa-euro-sign"></i>  250/2h
          </span>
          <span class="badge badge-light ml-1">
            <i class="fas fa-euro-sign"></i>  250/2h
          </span>
          <span class="badge badge-light ml-1">
            <i class="fas fa-euro-sign"></i>  250/2h
          </span>
          <span class="badge badge-light ml-1">
            <i class="fas fa-euro-sign"></i>  250/2h
          </span>
          <span class="badge badge-light ml-1">
            <i class="fas fa-euro-sign"></i>  250/2h
          </span>
    </div>
</body>
</html>

i changed <p> tag to <div>

Upvotes: 1

Related Questions