Improving alignment and spacing in Bootstrap 4 grids and columns

As a newcomer to Stack Overflow and Bootstrap, I am encountering issues with using two columns of size 2 and 10. When implemented, they overlap each other; however, adjusting them to sizes 3 and 9 results in too much space between them.

I attempted to find a solution on Stack Overflow by referring to this thread about bootstrap columns overlapping, but even after ensuring that my column sum equaled 12 for every row, the issue persisted.

Below is an excerpt from my HTML code:

<!doctype html>
<html lang="en">
<head>
    <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" href="css/bootstrap.min.css" type="text/css">
    <link rel="stylesheet" href="customcss.css" type="text/css">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

</head>
<body>
        <div class="container-fluid">
                 <div class="row">
                     <div class="col-lg-2">
                         <div id="sidebar" class="customdiv" style="background-color: green;">
                             <ul>
                                 <li><h1 style="margin-left: -15px">project</h1></li>
                                 <li><h1 style="margin-left: 15px">part1</h1></li>
                             </ul>
                                 <hr style="background-color: gold; height: 2px">
                                 <br>
                             <ul id="list-header">
                                 <li>project</li>
                                 <li>project</li>
                                 <li>project</li>
                                 <li>project
                                     <ul>
                                             <li>project</li>
                                             <li>project</li>
                                             <li>project</li>
                                         </ul>
                                 </li>
                                 <li>project
                                     <ul>
                                             <li>project</li>
                                             <li>project</li>
                                             <li>project</li>
                                             <li>project</li>
                                         </ul>
                                 </li>
                             </ul>
                         </div>
                     </div>

                     <div class="col-lg-10">
                         <div class="customdiv">
                             <img src="zoo.jpg" class="img-fluid">
                         </div>
                     </div>
                 </div>
             </div>
</body> 
</html>

Accompanied by my CSS code:

 html,body {
     height: 100%;
      }

 #sidebar{
     width: 250px;
     position: fixed;
     left: 250px;
     height: 100%;
     margin-left: -250px;

 }


 #list-header li{
     padding-top: 10px;
     padding-bottom: 10px; }

 .customdiv li {
     display: block; 
}

Providing the following output:

Click here for the displayed output

Also viewable when resizing the window:

Reduced window size result

Despite attempting suggested methods, excessive white space persists between elements.

Excessive white space remains visible despite method usage.

Answer №1

To effectively structure your layout, utilize the column grids provided below and remember to include the "img-responsive" class for images that will scale nicely within the parent element.

 <div class="col-md-6 col-sm-6 col-lg-6 col-xs-6">
    //sidebar content
 </div>

<div class="col-md-6 col-sm-6 col-lg-6 col-xs-6">
    //image content
    <img class=".img-responsive" src="zoo.jpg" />
 </div>

Prior to development, I recommend reviewing the following resources:

Reference 1

Reference 2

Image Reference 1

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

Add an element to the end within a separate div

I am facing a challenge where I need to rearrange ten divs with the class pcre within a single div identified by huge. The task involves moving the clicked div, which has the class pcre, to be placed at the end of the div with an id of huge using jQuery. ...

Exploring the relationship between Delphi and CSS in terms of the box model concept

I am currently working with a Delphi program on Windows to create HTML content. The challenge I am facing is achieving pixel-perfect WYSIWYG while dealing with text-wrap issues. When I generate the HTML from Delphi, the layout looks like this: -- ------- ...

Executing PHP Code following a JavaScript Confirmation Box: Best Practices

How can I run the following code in PHP? var answer = window.confirm("Do you want to overwrite the file..."); Based on the user's selection of "OK" or "CANCEL"; If the user chooses "OK", I need to execute the following PHP code without using AJAX. ...

WindiCSS classes are not functioning properly within a Nuxt application

I've been encountering some difficulties with WindiCSS. The classes are not being applied to the elements as expected. I attempted to install an older version of Windi, but the issue persisted. I even tried switching to Tailwind instead of Windi, but ...

Reaching SVG with CSS

Is it possible to target SVG elements with CSS? In older versions of IE, they display like broken images and I want to hide them using modernizr. I'm looking for a solution like the following... .no-svg object[type=svg] { display:none; } I have be ...

Optimal method for aligning decimal point of price within a django template

I need to show the total amount of money a user has spent in a table. I would like the display of the amount to be clean, but it currently looks like this: https://i.sstatic.net/kOpQ3.png I want the decimal point to line up perfectly on the black s ...

Unable to append item to document object model

Within my component, I have a snippet of code: isLoaded($event) { console.log($event); this.visible = $event; console.log(this.visible); this.onClick(); } onClick() { this.listImage = this.imageService.getImage(); let span = docu ...

I am having trouble getting pagify.js to function properly

Looking to incorporate the pagify.js plugin into my website by following the steps on Github. After downloading the repo, I tried opening the index page in Chrome for a preview, but encountered errors (see image). https://i.sstatic.net/WHOWS.png Need h ...

The navigation for Rails 5.0/Jquery Mobile is no longer responsive after a single click on the designated button

I've been struggling with this issue for a while now without any luck. The mobile navigation seems to be functioning correctly, but only when I refresh the page on my phone. After clicking on a list item, the navigation button becomes unclickable. I m ...

"What is the significance of the .default property in scss modules when used with typescript

When dealing with scss modules in a TypeScript environment, my modules are saved within a property named default. Button-styles.scss .button { background-color: black; } index.tsx import * as React from 'react'; import * as styles from ' ...

Having trouble displaying Json data on an HTML page?

I am trying to incorporate a local JSON file into an HTML page using JavaScript. I have successfully loaded the data from the JSON file into the console, but I'm encountering issues when trying to display it on the HTML page. Could someone please revi ...

Utilizing Chart.js to extract and display specific data values from an external JSON file

I am currently engaged in a journey of self-exploration where I aim to create a chart depicting the number of anime shows with comedy or fantasy genres. The data for my chart will be sourced from an external JSON file (anime.json) on my computer. Initially ...

Designing Checkboxes and Radio Buttons

I am seeking a way to customize the appearance of checked and unchecked checkboxes using images without modifying the HTML structure. I would prefer not to add labels, classes, or IDs to the elements. The provided example only works in Webkit browsers, s ...

Having trouble with JSON/jQuery syntax?

I am attempting to populate a set of DIVs with image backgrounds by reading images from a specific folder. The jQuery code I have written is shown below: $.getJSON('../functions.php', function(images) { images.each( function() { $('#m ...

Can Array Values from Different Functions be Merged?

After running my code, you will notice that when a user inputs the quantity for a room, selects check-in and check-out dates, and clicks submit, two tables are displayed. The first table shows the room name, the entered quantity, and the price based on the ...

Tips for verifying that a file has not been selected in Croppie

Whenever I use croppie to crop images on my website, everything works fine when I select an image and upload it. But if I try to crop and upload without selecting an image, a black image gets uploaded instead. How can I validate if the file upload is empty ...

Ways to display a specific section on an HTML page using AngularJS

Main page content <div class="row"> <div class="col-md-3"> link 1 link 2 link 3 . . . </div> </div> <div class="col-md-9"> <div ng-view></div> </div& ...

How to execute a JavaScript function within a Jinja for loop

I am currently working on an HTML page where the variable schedule contains a series of sequential decimal numbers representing seconds. My goal is to develop a function in JavaScript/jQuery that can convert these decimal numbers into time format. However ...

How can I design a form that resembles the sign-in form used by Google?

Currently, I am in the process of creating a contact form for a website that is inspired by the design of Google's material sign-in form. I have successfully implemented an effect where clicking on the input field causes the label to change its posit ...

Having trouble customizing the HTML range input?

I am looking to customize the appearance of a range input slider. Specifically, I want the slider to be green for the lower portion (where the thumb has moved) and grey for the remaining section. I have successfully changed the default styles from blue and ...