Troubleshooting Bootstrap Grid Alignment Problem During Zooming

I'm facing an issue with the alignment of my bootstrap grid.

Currently, I have three main columns in my layout - one for the left sidebar, one for the blog posts, and one for the right sidebar.

My challenge lies in trying to add a yellow bar on top of both the left and right sidebars. While I've managed to place it successfully on the left sidebar, I'm struggling to keep it fixed on the right sidebar. It tends to shift away when I zoom in or out, unlike the one on the left.

Below is my index.php code featuring the sidebars:


 <div class="row">
 <div class="col-md-5">
  </div>
  <div class="col-md-1">
  </div>
 <div class="col-md-4">
 </div>
 <div id="maineverything">
 <div class="col-md-3">
 <?php get_search_form(); ?>
 <?php get_sidebar('1'); ?>
 </div>
 <div class="col-md-7 blog-main">
 <div class="blogtitle">
 <p>PAKU SQUAD <span class="subheader1">BLOG</span></p>
<hr>
</div>    
<?php 
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile;?> 
    <nav>
     <ul class="pager">
       <li> <?php next_posts_link( 'Older Posts >>>' ); ?> </li>
       <li> <?php previous_posts_link( '<<< Newer Posts' ); ?></li>
     </ul>
    </nav> 
   <?php
   endif; 
   ?>
  </div> <!-- /.blog-main -->   
<div class="col-md-2">
<?php get_sidebar('2'); ?>
</div>
</div>
</div> <!-- /.row -->

And this is the css code related to my bootstrap grid:

/* Column Codes */
.row {
padding: 100px;
}
#maineverything {
padding-left: 150px;
display: inline-block;
max-width: 100%;
width: 100%;
height: 100%;
}
.col-md-2 {
border-bottom: 2px solid #a7a7a7;
max-height: 100%;
height: 1920px;
width: 250px;
background-color: #f0f0f0;
}
.col-md-3 {
border-bottom: 2px solid #a7a7a7;
max-height: 100%;
height: 1920px;
width: 250px;
background-color: #f0f0f0;
}
.col-md-4 {
margin-right: 47px;
float:right;
max-width:100%;
width: 250px;
height: 50px;
background-color: #feb300;
}
.col-md-5 {
padding-top: 50px;
max-width:100%;
margin-left: 150px;
width: 250px;
height: 30px;
background-color: #feb300;
}
.col-md-7 {
max-height: 100%;
height: 1920px;
border-bottom: 2px solid #a7a7a7;
}

Answer №1

To ensure proper Bootstrap HTML Structure, it's important to include a row within the container div and use col-md-* in the row. For more information, you can refer to the Bootstrap Grid System at https://www.w3schools.com/bootstrap/bootstrap_grid_system.asp. The bootstrap width is applied by default, so there is no need to manually apply width, padding, and margins. I've made some adjustments to your HTML structure by adding a container and removing unnecessary CSS. Please review the changes now.

/* Updated Column Codes */
.row {
padding: 0px 100px;
}
#maineverything {
display: inline-block;
max-width: 100%;
width: 100%;
height: 100%;
}
.col-md-2 {
border-bottom: 2px solid #a7a7a7;
background-color: #f0f0f0;
}
.col-md-3.bgyellow {
height: 30px;
background-color: #feb300;
}
.bgyellow2 {
height: 50px;
background-color: #feb300;
}
.col-md-3 {
background-color: #f0f0f0;
}
.col-md-4 {
height: 50px;
background-color: #feb300;
}
.col-md-5 {
height: 30px;
background-color: #feb300;
}
.col-md-7 {
border-bottom: 2px solid #a7a7a7;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
 <div class="col-md-3 col-xs-3 bgyellow">
  </div>
  <div class="col-md-7 col-xs-7">
  </div>
 <div class="col-md-2 col-xs-2 bgyellow2">
 </div>
 </div>
 </div>
 <div id="maineverything">
 <div class="container">
 <div class="row">
 <div class="col-md-3 col-xs-3">
 <?php get_search_form(); ?>
 <?php get_sidebar('1'); ?>
 </div>
 <div class="col-md-7 col-xs-7 blog-main">
 <div class="blogtitle">
 <p>PAKU SQUAD <span class="subheader1">BLOG</span></p>
<hr>
<?php 
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile;?> 
    <nav>
     <ul class="pager">
       <li> <?php next_posts_link( 'Older Posts >>>' ); ?> </li>
       <li> <?php previous_posts_link( '<<< Newer Posts' ); ?></li>
     </ul>
    </nav> 
   <?php
   endif; 
   ?>
</div>

  </div> <!-- /.blog-main -->   
<div class="col-md-2 col-xs-2">
<?php get_sidebar('2'); ?>
</div>
</div> <!-- /.row -->
</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

Build a table with consistent columns and flexible rows utilizing CSS and HTML

Just starting out with CSS/HTML and looking for guidance on creating a table with a variable number of rows. Any tips on how to achieve this using CSS? I'm aiming to replicate a table with a similar structure, but struggling to figure out how to defin ...

preclude any dates prior to the chosen date

I need a solution for a scenario where I have 5 datepickers in sequence. When I select a date on the first picker, all previous dates should be disabled when selecting on the next picker. Additionally, once a date is selected on one picker, the following ...

When running Javascript, the code is displayed rather than being executed

I have a current MVC - C# application that generates various "popup" screens containing necessary information. I wanted to apply the same method to create a popup displaying a version history (listing the Versions with their corresponding changes). Howeve ...

Ensure that the "position: absolute" is anchored to the document rather than the parent container

How can I add a div to any section of the webpage and have it positioned absolutely in relation to the entire document, rather than being affected by a parent element with relative positioning? ...

Unable to mark checkboxes in Bootstrap 4 Dropdown (triggered by vue.js) due to unresponsive behavior

When using Vue.js to open a Bootstrap Dropdown, I encountered an issue with selecting custom checkboxes within the dropdown menu. I have come across information about event.stopPropagation() potentially causing this problem, but I am unsure where to imple ...

Is there a way to ensure a grid container occupies the entire page?

Having trouble getting my grid display to cover the full size of the page. I have a grid with three columns controlled by two elements but it is not taking up the entire screen as expected. How can I make the grid fullscreen? .wrapper { display: grid; ...

Navigate through information within designated boundaries

In order to achieve vertical scrolling of a sidebar div and its content (3 links) between two points, I have utilized the CSS property position:fixed; top: 100px. While this setup works well initially by positioning the sidebar 100px down from the top and ...

VS code showing live server as installed but failing to function properly

After installing the live server extension, I noticed that my browser is not updating when I save my HTML or other files. What could be causing this issue? ...

What is the proper syntax for creating a layout with DIV and CSS?

Is there a way to create a master page for asp.net that includes 3 sections using div elements? I want to split the window into a left pane for tree view navigation, a top banner type div, and a main content window under it where child pages will be loaded ...

When the button is clicked, a modal will pop up

Looking for help in incorporating JavaScript to create a responsive modal that pops up with lyrics when a button is pressed in a table. Any assistance would be greatly appreciated. Note: Only the code for the table has been provided. Let me know if you&ap ...

Troubleshooting problem with CSS borders in Microsoft Edge Browser

I am currently working on implementing the concept found at the following link: https://www.w3schools.com/howto/howto_js_tabs.asp, but with the additional feature of borders around the elements. However, I have encountered an issue specifically with Micro ...

Looking for ways to ensure React is responsive and feeling a bit challenged by the React mentality?

I'm still getting the hang of ReactJS, and I've been facing some challenges with making React components responsive. For my app, I am utilizing react-tabs. It works well when the screen is wide, but I need to switch to a hamburger panel layout w ...

Replace all occurrences of the text/css style tag with an empty string using

I'm struggling with my PHP code and I need some assistance in removing the style type="text/css" tag. My goal is to replace this tag with an empty string. Here's the code snippet I've tried: if (strpos($inbox_message, '<style type= ...

Using grid system within the <nav> tag: a comprehensive guide

I've been working on incorporating the grid system with row and col using bootstrap 4.0, but I've run into an issue. When I use the <div> tag, everything seems to be working smoothly: <link href="https://maxcdn.bootstrapcdn.com/boots ...

SurveyJs Input component with additional feature

Currently working on a project using ReactJS and surveyjs. I am interested in incorporating an input element for capturing percentage values (%). I am curious if there is a solution for this: Integrating a bootstrap addon or similar feature with surveyjs ...

On screens with smaller dimensions, the divs intersect with each other

I have a project where I need to style each letter in its own box, arranged next to each other or in multiple rows with spacing between them. Everything looks great until I resize the screen to a smaller size or check it on mobile - then the letters in the ...

Having trouble getting the CSS animation to work properly with the text

Update: The direct link is working fine, unlike the rocketscript version. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> I have been attempting to animate word rotati ...

Tips on utilizing toggleClass to display only the currently active item and obtaining the active class name

I am new to Jquery and CSS/scss and I have successfully created a dynamic boostrap card that resembles a record player. The goal is to generate multiple boostrap cards based on the data in DB, but for simplicity, I am showing only 2 examples below. My ques ...

Stacking cards with Bootstrap4

Just starting to work with bootstrap and I'm currently focusing on learning how to stack cards. Here is the code I have: <div id="home"> <div class="row"> <div class="col-12 col-sm-6 col-md-4"> <div class= ...

The items are misaligned in a horizontal position

The 4 divs are styled with a width of 23% and displayed using inline-block. They have a fixed height of 220px and no margin applied. However, the issue arises as they are not aligning horizontally Despite attempting to adjust the height and width paramete ...