How to change the border color of a Modal Bootstrap

Asked

Viewed 859 times

3

I created a modal with bootstrap and I would like to know how I can change the border color of the modal without changing the structure of it, thanks in advance!

2 answers

3

You can use in class .modal-content one box-shadow in place of border for example, because the border occupies "space" in the box-model and the box-shadow nay.

Follow an example.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Page Title</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" media="screen" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" />
  <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<style>
  .modal-content {
    box-shadow: 0 0 0 5px red;
    border: none;
  }
</style>
</head>
<body>
  
    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
        Launch demo modal
      </button>
      
      <!-- Modal -->
      <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div class="modal-body">
              ...
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
              <button type="button" class="btn btn-primary">Save changes</button>
            </div>
          </div>
        </div>
      </div>
  
  <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
</body>
</html>

  • 1

    Thank you very much for your reply Hugo!

  • @Afonso no problem my dear! abs

2


Isn’t it the same way as the other html elements? Add the following to your html tag:

style="border-color: yellow;"

After class="modal-content"

To stay this way:

<div class="modal-content" style="border-color: yellow;>"

  • I forgot what border-color existed, thanks anyway

Browser other questions tagged

You are not signed in. Login or sign up in order to post.