Specify Modal Size

Asked

Viewed 1,396 times

1

I added a modal to my site, and I’m trying to change the size of it. But as much as I change his css , does not apply on the site, I’m changing in the file bootstrap.min.css from my site, as in the image below

inserir a descrição da imagem aqui

Can you help me ?

----------------------------After editing ----------------------------- Meu index

inserir a descrição da imagem aqui

  • Luis, make your HTML and full CSS easier to answer. Even with <head>

2 answers

2

You must not change bootstrap.min.css, what should be done is to define the style in your own css that should be declared after bootstrap;

Add the class:

.modal { 
    width: 700px; 
}
  • I changed but mine so does not apply ,

1


You have to override in class <div class="modal-dialog"> bootstrap.

.modal-dialog {
    width: 400px !important; /* aqui vc coloca a largura que deseja */
    margin: 30px auto;
}

Kind of:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.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-dialog {
        width: 400px !important; /* aqui vc coloca a largura que deseja */
        margin: 30px auto;
    }
</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://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>

  • didn’t work, I have no idea what I’m doing wrong, can take a look at my question I gave more details

  • @luismatheus edited my answer as a change that can solve the problem. I put the width in the Father class that I suggested earlier. I think now go, test there!

Browser other questions tagged

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