I recently utilized Bootstrap to create a responsive website, but I've encountered an issue where the space between columns has disappeared. Any suggestions on how to rect

I noticed that when I applied Bootstrap, the flexibility between boxes disappeared. I want to achieve a layout similar to image 2 and also add spaces between the boxes or div elements.

.alignboxes{
    padding-top:40px;
    display: flex;
    justify-content: space-evenly;
    padding-bottom: 20px;
}
.box1,.box2,.box3,.box4,.box5,.box6 {
    background-color: white;
    width:200px;
    height:100px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0px 0px 10px -2px rgba(0,0,0,0.75);
   
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Responsive</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="bootstrap-4.4.1-dist/bootstrap-4.4.1-dist/css/bootstrap.min.css">
</head>
<body>
    
<div class="container">
    <div class="row alignboxes"> 
        <div class=" col-md-offset-2 col-xs-12 col-sm-6 col-md-4 col-lg-4 box1"><img src="images/onlinesadqah.png" alt=""width="70px" height="70px"></div>
        <div class=" col-md-offset-2 col-xs-12 col-sm-6 col-md-4 col-lg-4 box2"><img src="images/welfare.png" alt="" width="70px" height="70px"></div>
        <div class=" col-md-offset-2 col-xs-12 col-sm-6 col-md-4 col-lg-4 box3"><img src="images/medical.png" alt="" width="70px" height="70px"></div>
        <div class=" col-md-offset-2 col-xs-12 col-sm-6 col-md-4 col-lg-4 box4"><img src="images/Dastarkhwan.png" alt=""width="70px" height="70px"></div>
        <div class=" col-md-offset-2 col-xs-12 col-sm-6 col-md-4 col-lg-4 box5"><img src="images/ROPLANT.png" alt="" width="70px" height="70px"></div>
        <div class=" col-md-offset-2 col-xs-12 col-sm-6 col-md-4 col-lg-
 4 box6"><img src="images/education.png" alt="" width="70px" height="70px"></div>
    </div>
</div>
</body>
</html>

Here is the link to image 1 with Bootstrap:
https://i.sstatic.net/wT1dN.jpg

And here is image 2 before applying Bootstrap:
https://i.sstatic.net/CGU4c.jpg

Answer №1

Looking to make adjustments to the alignboxes and include margin in the box css properties:

.alignboxes {
  display: grid;
  grid-template-columns: auto auto auto;
}
.box1,.box2,.box3,.box4,.box5,.box6 {
    background-color: white;
    width:200px;
    height:100px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0px 0px 10px -2px rgba(0,0,0,0.75);
    margin: 5px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Responsive</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="bootstrap-4.4.1-dist/bootstrap-4.4.1-dist/css/bootstrap.min.css">
</head>
<body>

<div class="container">
    <div class="row alignboxes"> 
        <div class="box1"><img src="images/onlinesadqah.png" alt=""width="70px" height="70px"></div>
        <div class="box2"><img src="images/welfare.png" alt="" width="70px" height="70px"></div>
        <div class="box3"><img src="images/medical.png" alt="" width="70px" height="70px"></div>
        <div class="box4"><img src="images/Dastarkhwan.png" alt=""width="70px" height="70px"></div>
        <div class="box5"><img src="images/ROPLANT.png" alt="" width="70px" height="70px"></div>
        <div class="box6"><img src="images/education.png" alt="" width="70px" height="70px"></div>
    </div>
</div>
</body>
</html>

This solution has been successfully implemented.

Answer №2

Enhance the structure by adding an additional div inside and incorporating margin as shown below:

.alignboxes {
  padding-top: 40px;
  justify-content: space-evenly;
  padding-bottom: 20px;
}

.alignboxes > * {
  display: flex;
  justify-content: center;
  align-items: center;
}

.alignboxes > * > * {
  background-color: white;
  max-width: 200px;
  width:100%;
  height: 100px;
  margin: 25px 5px;
  box-shadow: 0px 0px 10px -2px rgba(0, 0, 0, 0.75);
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
  <div class="row alignboxes">
    <div class=" col-md-offset-2 col-12 col-sm-6 col-md-4">
      <div class="d-flex"><img src="https://i.picsum.photos/id/1074/30/30.jpg" class="m-auto"></div>
    </div>
    <div class=" col-md-offset-2 col-12 col-sm-6 col-md-4">
      <div class="d-flex"><img src="https://i.picsum.photos/id/1074/30/30.jpg" class="m-auto" ></div>
    </div>
    <div class=" col-md-offset-2 col-12 col-sm-6 col-md-4">
      <div class="d-flex"><img src="https://i.picsum.photos/id/1074/30/30.jpg" class="m-auto" ></div>
    </div>
    <div class=" col-md-offset-2 col-12 col-sm-6 col-md-4">
      <div class="d-flex"><img src="https://i.picsum.photos/id/1074/30/30.jpg" class="m-auto" ></div>
    </div>
    <div class=" col-md-offset-2 col-12 col-sm-6 col-md-4">
      <div class="d-flex"><img src="https://i.picsum.photos/id/1074/30/30.jpg" class="m-auto" ></div>
    </div>
    <div class=" col-md-offset-2 col-12 col-sm-6 col-md-4">
      <div class="d-flex"><img src="https://i.picsum.photos/id/1074/30/30.jpg" class="m-auto" ></div>
    </div>
  </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Altering the appearance of a component that is currently selected and in use

Currently, I have incorporated a component with its selector within another component as shown below: <div class="col-xl-4" style="margin-bottom: 30px;"> <app-patient-info-accordion *ngIf="patient" [cardTitle]=&qu ...

Python code for clicking a button using Selenium

I'm having trouble closing popup windows in Selenium with Python. The button labeled "joyride-close-tip" is functioning correctly and closes the window, but the other two buttons are not working. What could be causing this issue? Even though I copied ...

Currently, I am experiencing difficulties with two specific aspects of the website I am working on - the hamburger menu and the slideshow feature

I'm having trouble with the menu on my website. It's not functioning as expected - the dropdown feature isn't working, and two items are not staying in the correct position under the parent ul despite attempts to position them using CSS. Add ...

Exploring Alternative Methods to Navigate Through Elements Using JQuery UI Autocomplete

After testing two different approaches: <div id = "team-search-container"> <label for="team-search" class = "text-center"> <input type = "text" id = "team-search"> </label> </div> With the following code sni ...

Emphasize the center row within a moving table

I am interested in developing a scrolling table where only 10 rows are visible at any given time, with the middle row set to stand out even during scrolling. The concept is that as the user scrolls down, the highlighted row changes progressively as they c ...

Pytest is not able to locate any elements on the webpage, yet the same elements can be easily found using the console

When using CSS or XPath in the console (F12), I am able to locate the element on the page. $$("span.menu-item[data-vars-category-name='Most Popular']") However, when trying to find the same elements with Selenium (pytest) using: driver.find_el ...

Instructions on implementing getJSON in this code

I recently set up a chained select box with JSON data to populate options, using this Fiddle. While the data is hardcoded for now, I am looking to load it using the $.getJSON() method. However, despite my efforts, I haven't been able to get the code r ...

Click to make the arrow come to life through animation!

I am brand new to coding and this is my inaugural code snippet: .container_menu { position: relative; top: 0px; left: 0px; width: 25px; height: 25px; } .container_menu .line-1 { background-color: black; width: 59%; height: 2px; positio ...

Ways to retrieve HTML tags from a website's DOM and shadowDOM

I am currently working on a project using NodeJS where I need to extract the HTML structure of multiple websites. However, I am facing some challenges with this task. My goal is to retrieve only the HTML structure of the document without any content. It is ...

The angular view is lacking a CSS class

index.html: <div ng-view="myview.html"></div> myview.html: <table class="table table-striped table-hover"> <tr> <td>Name</td> <td>Product</td> </tr> <tr ng-repeat="deal in deals" class="clickableR ...

Having difficulty retrieving the Area and Range information in ChartJS

I am new to working with HTML5 and ChartJS. I have noticed two different types of declarations when attaching JS Chart Versions 1.0.1 and 2.1.1. Can you please provide some insight into this? Additionally, I am facing an issue where the stripes behind the ...

Why are you leaving a trail of timestamps in your .css files?

Within certain source codes, I have observed the following: <link rel="stylesheet" href="/css/style.css?201007071609" type="text/css" /> This prompts my question: What is the purpose behind appending 201007071609 to style.css in the code snippet ab ...

Choosing an item from a dropdown menu in C# using Selenium in web assembly is proving to be ineffective

I am currently working on some automated tests using Selenium Web driver. I have been able to write a script that can locate the class, but I am facing difficulties in selecting one of the items from the drop down menu. Here is the script I have so far: ...

What is the best way to dynamically insert an image into an <li> element?

I am looking to enhance my menu by adding an image below each li item as a separator. How can I achieve this using CSS? I want the images to automatically appear whenever a new li tag is added to the ul. Here is the HTML code: <ul class="menu"> ...

Learn how to retrieve and transfer data from a MySQL database table to a hidden input field in an HTML form using PHP

I have a scenario where a user fills out the first form, submits it, and the details are saved in a database table. After that, I need to set a value from the data sent to the database into a hidden input field in the second form upon clicking a button. To ...

Employ the Google Charting library for creating a GeoChart that is currently not displaying

Hello everyone. I'm having a bit of an issue with my web page development. I've been trying to add a GeoChart, but no matter how many times I copy-paste the code from the Google developer's website, the map just won't show up. I must be ...

AgGrid's magical dropdown feature

Struggling to integrate a bootstrap-4 dropdown menu with AgGrid, I'm facing an issue where the data table overlaps the dropdown when the html is present. Attempts to increase the z-index have not yielded results. Below is the html code snippet: < ...

Unable to function in simplistic html/php code, 'Require' fails to operate as intended

I am facing an issue while attempting to import a header.php file into my index.php file. For some reason, it is not working as expected. header.php: <!DOCTYPE html> <html> <head></head> <body> <header> & ...

Automatically switch tabs upon pressing/scanning the Return key (using PHP, MySQL, and JavaScript)

Seeking assistance to resolve an ongoing issue that has been troubling me for the past few weeks. I am maintaining a basic web-based database to keep track of product serial numbers leaving our warehouse. The system is secure behind our firewall, so I&apo ...

Prevent the use of harmful language by implementing jQuery or JavaScript

Is there a way for me to filter certain words (such as "sex") using regex, even when people use variations like "b a d", "b.a.d", or "b/a/d"? How can I prevent these kinds of words from getting through? I'm trying to filter more than just one word - ...