skip to Main Content

Strange issue here. I’m employing a bootstrap grid

<div class="col-md-1"></div>
<div class="col-md-10"></div>
<div class="col-md-1"></div>

For my portfolio. On my laptop, which has a monitor of perhaps 16 inches, this looks fine. However, on my 24-inch monitor, the middle section looks oddly small, like it spans 8 columns instead of ten. Any idea why this would be? It is all inside a container class div.

EDIT: Here’s how it looks. And here’s a link

enter image description here

2

Answers


  1. You need to use .container-fluid instead of .container

    The latter has a max width of 1320px while the former has a max width of 100% and will span the entire width of the viewport.

    See the Bootstrap documentation

    See sample code below (expand to full page to see it better)

    div{
       border: 1px solid lightblue;
    }
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
    
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
    
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-1">a</div>
        <div class="col-md-10">middle</div>
        <div class="col-md-1">b</div>
      </div>
    </div>
    Login or Signup to reply.
  2. you can change the the grid size depending on screen size.
    This may help you. just add 3 grid type class for screen size –

    sm for small screen,

    md for medium screen and

    lg for large screen

    you only need to increase greed size for large screen.

    Hope this will work for your problem.

    <html lang="en">
        <head>
            <meta charset="UTF-8" />
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <title>Solution</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
            </head>
    
        <body>
          <div class="container">
            <div class="row">
              <div class="col-sm-1 col-md-1 bg-warning">a</div>
              <div class="col-sm-10 col-md-10 col-lg-12 bg-primary">middle</div>
              <div class="col-sm-1 col-md-1 bg-warning">b</div>
            </div>
          </div>
        </body>
    </html>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search