skip to Main Content

I’m trying to make a simple home page based on the "Responsive Content Titles" from this git repo: https://github.com/solodev/responsive-content-tiles

I have eight tiles and I want to put them into two rows (four tiles in each row). And this is my html and css files:

<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Portal</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" href="responsive-tiles.css">
  <style> h1 {text-align: center;} </style>
</head>
<body>
<h1>Portal</h1>
<div class="container">
  <section class="cms-boxes">
     <div class="container-fluid">
        <div class="row">
           <div class="col-md-4 cms-boxes-outer">
              <div class="cms-boxes-items cms-features">
                 <div class="boxes-align">
                    <div class="small-box">
                       <i class="fa fa-4x fa-laptop">&nbsp;</i>
                       <h3>
                           <a href="https://xxx">
                               Single studies
                           </a>
                        </h3>
                       <p>Each dataset xxx</p>
                    </div>
                 </div>
              </div>
           </div>
           <div class="col-md-4 cms-boxes-outer">
              <div class="cms-boxes-items cms-security">
                 <div class="boxes-align">
                    <div class="small-box">
                       <i class="fa fa-4x fa-cog">&nbsp;</i>
                       <h3>
                           <a href="https://xxx/xxx">
                               integrations
                           </a>
                        </h3>
                       <p>Multiple datasets</p>
                    </div>
                 </div>
              </div>
           </div>
           <div class="col-md-4 cms-boxes-outer">
              <div class="cms-boxes-items cms-scalability">
                 <div class="boxes-align">
                    <div class="small-box">
                       <i class="fa fa-4x fa-arrows-alt" aria-hidden="true"></i>
                       <h3>
                           <a href="https://xxx/xxx">
                           integrations
                           </a>
                        </h3>
                       <p>integrated.</p>
                    </div>
                 </div>
              </div>
           </div>
           <div class="col-md-4 cms-boxes-outer">
              <div class="cms-boxes-items cms-built">
                 <div class="boxes-align">
                    <div class="large-box">
                       <i class="fa fa-4x fa-file-code-o">&nbsp;</i>
                        <h3>
                         <a href="https://xxx">
                          atlas
                         </a>
                        </h3>
                       <p>Integration of data.</p>                     
                    </div>
                 </div>
              </div>
           </div>
        </div>
        <div class="row">
           <div class="col-md-4 cms-boxes-outer">
              <div class="cms-boxes-items cms-documentation">
                 <div class="boxes-align">
                    <div class="large-box">
                      <i class="fa fa-4x fa-cube" aria-hidden="true"></i>
                       <h3>
                         <a href="https://xxx">
                           atlas
                         </a>
                        </h3>
                       <p>indications were integrated.</p>
                    </div>
                 </div>
              </div>
           </div>
           <div class="col-md-4 cms-boxes-outer">
              <div class="cms-boxes-items cms-normal">
                 <div class="boxes-align">
                    <div class="large-box">
                      <i class="fa fa-camera-retro fa-4x">&nbsp;</i>
                       <h3>
                         <a href="https://xxx">
                           Normal 
                         </a>
                        </h3>
                       <p>Atlas </p>
                    </div>
                 </div>
              </div>
           </div>
           <div class="col-md-4 cms-boxes-outer">
              <div class="cms-boxes-items cms-security">
                 <div class="boxes-align">
                    <div class="large-box">
                       <i class="fa fa-4x fa-file-code-o">&nbsp;</i>
                        <h3>
                         <a href="https://xxx">
                           atlas
                         </a>
                        </h3>
                       <p>data</p>
                    </div>
                 </div>
              </div>
           </div>
           <div class="col-md-4 cms-boxes-outer">
              <div class="cms-boxes-items cms-scalability">
                 <div class="boxes-align">
                    <div class="large-box">
                      <i class="fa fa-4x fa-cube" aria-hidden="true"></i>
                       <h3>
                         <a href="https://xxx/home">
                           placeholder
                         </a>
                        </h3>
                       <p>placeholder</p>
                    </div>
                 </div>
              </div>
           </div>
        </div>

     </div>
  </section>
</div>
</body>
</html>

responsive-tiles.css

 section.cms-boxes .cms-boxes-outer {
    text-align: left;
    margin-bottom: 6px;
    padding: 0 3px;
}
section.cms-boxes .cms-boxes-outer .cms-boxes-items {
    height: 350px;
    display: table;
    width: 100%;
}
section.cms-boxes .cms-features {
    background-color: #b70457;
    background-size: cover;
}
section.cms-boxes .boxes-align {
    display: table-cell;
    vertical-align: middle;
}
section.cms-boxes .small-box, section.cms-boxes .large-box {
    max-width: 350px;
    margin: 0 auto;
    text-align: center;
}
section.cms-boxes .cms-boxes-items h3 {
    font-size: 35px;
    color: #fff;
    font-weight: 400;
    line-height: 37px;
    text-align: center;
    margin: 20px 0 10px;
/*    text-transform: uppercase; */
}
section.cms-boxes .cms-boxes-outer .cms-boxes-items p {
    color: #fff;
}
section.cms-boxes .boxes-align {
    display: table-cell;
    vertical-align: middle;
}
section.cms-boxes .cms-boxes-outer .cms-boxes-items {
    height: 350px;
    display: table;
    width: 100%;
}
section.cms-boxes .cms-features {
    background-color: #b70457;
    background-size: cover;
}
section.cms-boxes .cms-boxes-outer .cms-boxes-items {
    height: 350px;
    display: table;
    width: 100%;
}
section.cms-boxes .cms-security {
    background-color: #ff7f00;
}

section.cms-boxes .cms-scalability {
/*    background: url(images/scalability.jpg) 0 0 no-repeat; */
    background-color: #999999;
    background-size: cover;
}
section.cms-boxes .cms-boxes-outer {
    text-align: left;
    margin-bottom: 6px;
    padding: 0 3px;
}
section.cms-boxes .cms-built {
/*    background: url(images/customer-service.jpg) 0 0 no-repeat; */
    background-color: #6495ED;
    background-size: cover;
}

section.cms-boxes .cms-boxes-items:hover {
  opacity: .2;
  cursor: pointer;
}
section.cms-boxes .cms-normal {
    background-color: #ccebc5;
    background-size: cover;
}

section.cms-boxes .cms-documentation {
    background-color: rgb(66, 16, 88);
}

My goal is to have four tiles in a row but only three can be placed in a row right now. I’m new to html and css and I can’t seem to identify the part in responsive-tiles.css or other css files that are referred in the html file are responsible for this.
This is how it looks currently

Any help is appreciated!

2

Answers


  1. in Bootstrap CSS, content is divisible by 12.
    A 100% content contains 12 columns.

    If you want 3 columns inside a row you must therefore have :

    12 / 3 = 4 >>

    <div class="row">
      <div class="col-4">...</div>
      <div class="col-4">...</div>
      <div class="col-4">...</div> 
    </div>
    

    Now, if you want 4 columns,
    12 / 4 = 3 i.e.

    <div class="row">
      <div class="col-3"> ... </div>
      <div class="col-3"> ... </div>
      <div class="col-3"> ... </div>
      <div class="col-3"> ... </div>
    </div>
    

    The col-md ( medium size ), col-sm ( small size ), etc … can be useful for responsive contents

    <!-- Stack the columns on mobile by making one full-width and the other half-width -->
    <div class="row">
      <div class="col-12 col-md-8">....</div>
      <div class="col-6 col-md-4">....</div>
    </div>
    

    You can find more explainations on Bootstrap website
    getbootstrap.com/docs/5.0/layout/grid/

    Login or Signup to reply.
  2. As I mentioned in the comments, the screen is divisible by 12. So you just divide the number of spaces you need by 12 in this case, we have 12 / 4 spaces gives us a value of 3.
    And as per your follow up question you could hard code them a bit with the style command to force them to be a certain width. Perhaps 200px isn’t correct, so update to a value that works for you, but this should get you on the right track. I used the md for medium sized screen but you can adjust as needed or use a flex version if you plan on dual web and mobile deployment.

    <div class='row'>
      <div style='width:200px;' class='col-md-3'> col 1 </div>
      <div style='width:200px;' class='col-md-3'> col 2 </div>
      <div style='width:200px;' class='col-md-3'> col 3 </div>
      <div style='width:200px;' class='col-md-3'> col 4 </div>
    </div>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search