-1

I have two grid columns in my footer, and I would like to center them directly in the center. Currently, the columns and content are centered, but there is a huge space between the two grid columns. I am using Bootstrap 4.

I have tried solutions from Remove spacing between cols and Remove gutter space for a specific div only but it does not seem to work for me.

I want to make the two columns to be side by side like this: https://i.stack.imgur.com/uOPRB.jpg .

This is my html:

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>Cuppela</title>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <script src="js/bootstrap.min.js" type="text/javascript"></script>
    <script src="js/popper.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css">
    <link rel="stylesheet" href="css/test.css" type="text/css">
</head>

<body>

<div id="nav-menu">
    <nav id="main-nav" class="navbar navbar-expand-md fixed-top navbar-dark">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
            <span class="navbar-toggler-icon"></span>
          </button>
          <div class="collapse navbar-collapse" id="collapsibleNavbar">
            <ul class="nav navbar-nav mx-auto">
                <li class="nav-item">
                    <a class="nav-link" href="#">Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Shop</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">About</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Contact</a>
                </li>
            </ul>
        </div>
    </nav>
</div>

<script>

$(window).scroll(function()
{
    var $theNavBar = $('#main-nav');
    if($(document).scrollTop() > ($theNavBar.height()+10))
    {
        $theNavBar
            .removeClass('bg-transparent')
            .addClass('bg-dark');
    }
    else
    {
        $theNavBar
            .addClass('bg-transparent')
            .removeClass('bg-dark');
    }
});

</script>

<div class="container-fluid" id="top-main" style="background-image: url('images/cake_six.jpg');"> 

    <div id="top_text">
        <h1>Cuppela Made With Sugar</h1>
        <p style="font-size: x-large;">Delicious Homemade Cakes</p>
    </div>
    
</div>

<div id="best-sellers "class="container">
    <h2>Best Sellers</h2>
    <hr>
    <div id="best-seller-cakes" class="row">
        <div class="col-xs-12 col-sm-6 col-lg-3">
            <img src="images/cake_three.jpg">
            <h4>Good<br>Cakes</h4>
            <p>Delicious Cake with Awesome Goodness</p>
        </div>
        <div class="col-xs-12 col-sm-6 col-lg-3">
            <img src="images/red_velvet_cake.jpeg">
            <h4>Awesome<br>Cakes</h4>
            <p>Delicious Cake with Awesome Goodness</p>
        </div>
        <div class="col-xs-12 col-sm-6 col-lg-3">
            <img src="images/strawberry_cake.jpg">
            <h4>Great<br>Cakes</h4>
            <p>Delicious Cake with Awesome Goodness</p>
        </div>
        <div class="col-xs-12 col-sm-6 col-lg-3">
            <img src="images/cake_three.jpg">
            <h4>Delicious<br>Cakes</h4>
            <p>Delicious Cake with Awesome Goodness</p>
        </div>
    </div>
</div>

<footer class="page-footer font-small bg-dark">

  <div class="container-fluid">

    <div id="footer-content" class="row no-gutters">

      <div id="address-details" class="col-md-6">

        <p>Feel free to contact us. We're always ready to help you.</p>
        <h5 class="text-uppercase font-weight-bold">Address</h5>
        <address>
        <dl>
                    <dt>Location:</dt>
                    <dd>Test Street 42, Block 330, 123456</dd>
        </dl>
        </address>
      </div>
      
      <div id="contact-details" class="col-md-6">

        <h5 class="text-uppercase font-weight-bold">Contact</h5>
        <address>
            <dl class="dl-horizontal-mod-1">
                <dt>Phone</dt>
                <dd><a href="callto:#" class="text-primary">9000 0000</a></dd>
            </dl>
            <dl class="dl-horizontal-mod-1">
                <dt>Email</dt>
                <dd><a href="mailto:#" class="text-primary">test@demo.com</a></dd>
            </dl>

             <dl class="dl-horizontal-mod-1">
                <dt>Facebook</dt>
                <dd><a href="#" class="text-primary">Cuppela Made With Sugar</a></dd>
            </dl>
        </address>

      </div>

    </div>

  </div>

  <div id="copyright" class="footer-copyright text-center py-3">
    © 2021 Copyright:
    <a>Cuppela</a>
  </div>

</footer>
</body>
</html>

This is my css:

body{
    margin: 0px;
}

li a:hover {
    background: #ff9900;
    border-radius: 10px;
}

li a{
    color: white !important;
}

.nav-link{
    padding: 0 0 .2rem
}

#top-main{
    height: 100vh;
}

#nav-menu{
    font-size: medium;
    position: relative;
}

#top_text{
    color: white;
    text-align: center;
    position: relative;
    top: 50%;
    left: 50%;
    /* bring your own prefixes */
    transform: translate(-50%, -50%);
}

h1{
    font-size: 500%;
    text-align: center;
}


h2{
    text-align: center;
}

img
{
    width: 260px;
    height: 170px;
}

#best-sellers{
    text-align: center;
}

#best-seller-cakes{
    text-align: center;
}

h4
{
    font-size: x-large;
    text-transform: uppercase;
    font-weight: bold;
    font-family: Georgia, 'Times New Roman', Times, serif;
}

#footer-content
{
    text-align: center;
    color: white;
}

#copyright
{
    color: #ff9900;
}

mmm000
  • 89
  • 8

2 Answers2

1

enter image description here

We are pointing to the marked class. Do the given code instead of yours.

class="row justify-content-center"

And then you need to change the column width. Here, the problem is, you have put col-md-6 for each column. So, each of the column is trying to take half of the width and creating spaces. Just put

class="col-3"

instead of the marked codes.enter image description here

Hopefully this will work.

shuhat36
  • 251
  • 2
  • 5
0

You need to use flex or grid system. I personally prefer flex all the way. Add this code by the end of the css file. Hopefully it will work.

.row{
    display: flex;
    justify-content: center;
}
shuhat36
  • 251
  • 2
  • 5
  • Hi, it does not seem to work for me. I am currently using Bootstrap 4 and I tried to add .no-gutters but there will still be that gap. – mmm000 Aug 06 '21 at 03:35
  • Oh, I missed the point that you are using bootstrap. I am providing the solutions as a new answer. – shuhat36 Aug 06 '21 at 03:57