Alignment issues with columns in Bootstrap

In my layout, I have three columns with a container in each column. However, I am experiencing an unusual display issue: https://i.sstatic.net/CLT1q.png

An example of the desired display is shown here:

https://i.sstatic.net/4dCru.png

The three columns in question are my navbar, my card grid, and a zoom feature on one card. I want both my navbar and zoom column to be fixed at the top so that only the grid scrolls when I scroll down. I successfully applied the "fixed-top" attribute to the navbar, but encountered layout issues when doing the same for the zoom column.

This is a snippet of my HTML body:

<body data-spy="scroll" data-target=".navbar .fixed-top" data-offset="50">
    <div class="container-fill main_container">
        <div class="row no-gutters">
            <div class="col-sm-2 side_bar_n">  <!-- Navbar section -->
                <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion fixed-top" id="accordionSidebar">
                    ........ 

                </ul>
            </div>
            <div class="col-sm-7">  <!-- Card grid -->
                <div class="container grid_container">
                  <h1>Card Search</h1>
                  <div class="row no-gutters">
                      <div class="col-sm-2"><img src="cards/287044.jpg" class="rounded grid_space img-fluid" alt="Cinque Terre"></div>
                        ........
                      <div class="col-sm-2"><img src="cards/287044.jpg" class="rounded grid_space img-fluid" alt="Cinque Terre"></div>

                  </div>
                </div>
            </div>
            <div class="col-sm-2"> <!-- Card display -->
                <div class="container-fluid fixed-top">
                    <div class="card card_body">
                      <img class="card-img-top rounded" src="cards/368262.jpg" alt="Card image">
                          <div class="card-body">
                            <h4 class="card-title">Rythme of the Wild</h4>
                            <p class="card-text">Creature spells you control can't be countered.
                                                NonToken creatures you control have riot (+1/+1 or haste when entering the battlefield.)</p>
                            <a href="#" class="btn btn-primary">See Profile</a>
                          </div>
                    </div>
                </div>
            </div> 
        </div>
    </div>
</body>

Answer №1

Make sure to eliminate the container-fluid fixed-top classes from the card display division...

Additionally, boost the card size by changing col to col-sm-3

Check out the fiddle

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
  
  
<body data-spy="scroll" data-target=".navbar .fixed-top" data-offset="50">
  <div class="container-fill main_container">
    <div class="row no-gutters">
      <div class="col-sm-2 side_bar_n">
        <!-- Navigation bar goes here -->
        <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion fixed-top" id="accordionSidebar">
          ........
        </ul>
      </div>
      <div class="col-sm-7">
        <!-- Card grid section -->
        <div class="container grid_container">
          <h1>Search for a card</h1>
          <div class="row no-gutters">
            <div class="col-sm-2"><img src="cards/287044.jpg" class="rounded grid_space img-fluid" alt="Cinque Terre"></div>
            ........
            <div class="col-sm-2"><img src="cards/287044.jpg" class="rounded grid_space img-fluid" alt="Cinque Terre"></div>

          </div>
        </div>
      </div>
      <div class="col-sm-3">
        <!-- Adjusted card display area -->
        <div class="">
          <div class="card card_body">
            <img class="card-img-top rounded" src="cards/368262.jpg" alt="Card image">
            <div class="card-body">
              <h4 class="card-title">Rythme of the Wild</h4>
              <p class="card-text">Creature spells you control can't be countered. NonToken creatures you control have riot (+1/+1 or haste when entering the battlefield.)</p>
              <a href="#" class="btn btn-primary">View Profile</a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>

Answer №2

For a sleek layout, consider adding the float-right class to the column you want on the right side. Additionally, don't forget to include the clearfix class to all divs within the container class. Check out the modified code below for reference.

<body data-spy="scroll" data-target=".navbar .fixed-top" data-offset="50">
        <div class="container-fill main_container clearfix">
            <div class="row no-gutters">
                <div class="col-sm-2 side_bar_n">  <!-- Navigation bar here -->
                    <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion fixed-top" id="accordionSidebar">
                        ........ 
                    </ul>
                </div>
                <div class="col-sm-7">  <!-- Card grid -->
                    <div class="container grid_container clearfix">
                      <h1>Card Search</h1>
                      <div class="row no-gutters">
                          <div class="col-sm-2"><img src="cards/287044.jpg" class="rounded grid_space img-fluid" alt="Cinque Terre"></div>
                            ........
                          <div class="col-sm-2"><img src="cards/287044.jpg" class="rounded grid_space img-fluid" alt="Cinque Terre"></div>

                      </div>
                    </div>
                </div>
                <div class="col-sm-2 float-right"> <!-- Card display -->
                    <div class="container-fluid fixed-top clearfix">
                        <div class="card card_body">
                          <img class="card-img-top rounded" src="cards/368262.jpg" alt="Card image">
                              <div class="card-body">
                                <h4 class="card-title">Rhythm of the Wild</h4>
                                <p class="card-text">Creature spells you control can't be countered. Non-Token creatures you control have riot (+1/+1 or haste when entering the battlefield.)</p>
                                <a href="#" class="btn btn-primary">See Profile</a>
                              </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>

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

Can a nofollow attribute be added to concealed modal content in Bootstrap?

Query: I am dealing with a situation where I have a significant amount of disclaimer text within a modal on my website. This text is initially hidden (display:none) until a user clicks a button to reveal it. I want to prevent search engines from indexing t ...

Transform JSON data into an HTML table using PHP

My goal is to dynamically convert a JSON array into an HTML table using PHP. The challenge lies in the fact that this data can vary with each request, meaning the JSON may contain different arrays and/or different associated names. For example, I have two ...

What is the best way to retrieve a GWT textbox value using Selenium WebDriver?

I'm currently testing my GWT application with selenium, and the HTML generated by GWT Textbox appears like this: <input type="text" class="gwt-TextBox" > Even though there's no value visible in the code above, I can see text in the UI. Is ...

Creating a fully responsive HTML page with a fullscreen image background

Seeking help from someone who can assist me. I have a challenge in creating a webpage with a background image that fills its <div>. Here is the code I used: <style type="text/css> .myclassdiv { background-image:url('IMAGEURL') ...

Presenting information on an HTML webpage using the slidetoogle feature

< script > $(document).ready(function() { $("#flip").click(function() { $("#panel").slideToggle("fast"); }); }); < /script> When a button in a particular panel is clicked, I aim to display the details of that specific tuple ...

Tips for adjusting text to fit within a container without needing to use overflow:auto

Is there a way to prevent text overflow in a container without using the overflow:auto property? I've come across plugins that automatically reduce the text size, but I'm not keen on that solution. What I want is for long words or URLs to wrap on ...

Retrieving data from a Bootstrap range slider

Trying to retrieve a variable from a price range slider for my online store. I aim to display the value using PHP. Here is the snippet from my test.php file: <script> var slidervalue = $('#output').val(); </script> <?php ...

Using Google fonts offline: a step-by-step guide

Is it possible to download Google fonts and link them offline for a localhost webpage? ...

Bootstrap 4's hamburger icon in the navbar toggler displaying only two lines, rather than three

I have created a navbar using Bootstrap 4. Although the navbar is functional, I am facing an issue that I have not been able to resolve on my own. When collapsed, the hamburger icon only displays two lines instead of three. I suspect that the problem lie ...

Navigate between pictures using hover in jQuery

I am working on creating a feature where images cycle through individually every 2 seconds, but switch to the right image when its associated link is hovered. So far, I have managed to make the images show up on hover, but I am struggling with getting them ...

Customize your click event with conditional styling in React

When the onClick event is triggered, I am attempting to modify a class by calling my function. It appears that the function is successfully executed, however, the class does not update in the render output. Below is the code snippet: import React from &ap ...

Tips for managing the velocity of JavaScript navigation scrolling

Hey everyone, I recently discovered this incredibly helpful JavaScript sticky side navigation script and it works like a charm! However, since I don't know much about JS, I was wondering if there's a way to slow down the scrolling speed? functio ...

Achieving Perfect Alignment of Images Using HTML and CSS

I am currently working on designing a HTML/CSS layout for a Kiosk-style website. However, I am encountering some challenges in getting the alignment of images and text to appear exactly as desired. The goal is to have the logo and header remain fixed in ...

How can Bootstrap-Vue showcase an SVG image as a navigation item?

I need help positioning the Octocat image on the top right corner of a NavBar: In the Vue Snippet below, the icon is currently only visible if there is text inside the <b-nav-item>: <template> <div> <b-navbar toggleable="lg ...

Incorporate a video within the royal slider feature

Next is my deluxe slider code. This slider displays only images but I am looking to incorporate video as well. I have searched online and tried different solutions, but haven't found one that works for me. Can someone please guide me on how to achieve ...

Error in JQuery Document Ready AJAX function causing image to not load initially without a page refresh

Currently, I have a piece of customized code that extracts data from an XML file and uses this data to populate specific content on my webpage: $(document).ready(function() { $.ajax({ type: 'GET', url: 'config.xml?date=& ...

The background-size property fails to function properly on mobile devices

It's really puzzling why this issue is happening, perhaps it's due to my fatigue. The problem lies in the fact that the "background-size" property isn't functioning on my mobile devices; however, it works perfectly when I try to simulate it ...

Website design with a central vertical alignment and a subtle shadow effect

Yesterday I inquired about a website design featuring a shadow, but I have since created a better example and would like to pose the question again. My requirements are as follows: A vertically centered website; A shadow on the content block which may h ...

IE compatibility mode causing ckeditor dropdown to be hidden

When using the CKEditor editor bar inside a green div with another div below it, I noticed that when clicking on "font" or any other option that opens a dropdown menu, it gets hidden behind the bottom div. This issue seems to occur in browsers like Chrome ...

Aligning CSS Divs with Changing Content

Can someone help me with a CSS and DIV tags issue? I have a dynamic webpage and need guidance on creating a container DIV. Depending on the scenario, this container DIV will either hold one DIV with 50% width that needs to be centered or two side-by-side D ...