0

I got my bootstrap grid to work. But I'm having trouble trying to figure out how to get it to collapse at 750px.

This is what it's suppose to look like this when larger than 750px: Full-Size

and this is what it's suppose to look like when between 550px-750px: Mid-Size

anything smaller than 550 the Aside and Section parts disappear (which I was able to do using @media in my CSS file)

HTML:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="mystyle-A.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script>   
</head>

<body>
<div class="container-fluid">
      <div class="row">
           <div class="header">Header</div>
      </div>
      <div class="row">
           <div class="navigation-bar">Nav</div>
      </div>


 </div>
 <div class="container-fluid">
 <div class="row">
           <div class="col-sm mbody">
                <div class="article">Article</div>
           </div>
           <div class="col-sm mbody">
                <div class="row">
                     <div class="aside">Aside</div>
                </div>
                <div class="row">
                     <div class="section">Section</div>
                </div>
           </div>
      </div>
 </div>
 <div class="container-fluid">
      <div class="row">
           <div class="footer">Footer</div>
      </div>
 </div>
</body>
</html>                                     

CSS:

body {
 background-color: black;
 font-size: 2em; 
 text-align: center;

}

.mbody {
  margin: 0; 
  padding: 0; 

}

.header {
  background-color: cornflowerblue;
  height: 60px;
  text-align: center;
  width: 100%; 

}

.navigation-bar {
  background-color: khaki;
  height: 50px;
  text-align: center;
  width: 100%; 
}

.article {
  background-color: darkseagreen;
  height: 180px;
  text-align: center;
  width: 100%; 

}

.aside {
  background-color: goldenrod;
  height: 90px;
  text-align: center;
  width: 100%; 

}

.section {
  background-color: lightsteelblue;
  height: 90px;
  text-align: center;
  width: 100%; 

}

.footer {
  background-color: lemonchiffon;
  height: 40px;
  text-align: center;
  width: 100%; 

}

@media only screen and (max-width: 550px) {

.aside {
  display: none;

} 

.section {
  display: none;

}
}

It was easy to figure out the 550 using '@media' since I just have to not display it, but how could I use @media only screen and (max-width: 750px)to collapse it like the second picture?

tjw
  • 123
  • 2
  • 10

1 Answers1

0

550 and 750 isn't one of the standard breakpoint sizes.

https://getbootstrap.com/docs/4.0/layout/grid/#grid-options the following would be similar to what you are looking for, but would break between the full view at smaller than 768, and then would hide the aside and section at under 576

<div class="row">
    <div class="col-12">Header</div>
</div>
<div class="row">
    <div class="col-12">Nav</div>
</div>
<div class="row">
    <div class="col-12 col-md-9">Article</div>
    <div class="col-12 col-md-3">
        <div class="row">
            <div class="d-none d-sm-block col-12">Aside</div>
            <div class="d-none d-sm-block col-12">Section</div>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-12">footer</div>
</div>

If you really want to break at 750, and 550, you can override the breakpoints. See How to extend/modify (customize) Bootstrap 4 with SASS

charley
  • 124
  • 1
  • 5