Trouble Ensues as CSS Tables Misalign with Bootstrap Framework

After meticulously slicing up multiple images in Photoshop and exporting them with the necessary CSS table mark-up, everything appeared to be perfectly aligned. However, once the Bootstrap CSS file was included on the page, some of the images started going out of alignment on desktop browsers, while strangely remaining intact on mobile devices.

An illustrative example is provided below where a particular image (#3) is off by 4 pixels with Bootstrap 3 and 6 pixels with Bootstrap 4, causing an undesirable misalignment:

Table Layout without Bootstrap

div.Table_01 {
position:absolute;
left:0px;
top:0px;
width:272px;
height:340px;
}
.
.
.
body {
  background: yellow;
}
<div class="Table_01">
<div class="jyd-01">
....
.....
</div>

The issue arises when Bootstrap is added as demonstrated in the following snippet:

div.Table_01 {
position:absolute;
left:0px;
top:0px;
width:272px;
height:340px;
}
.
.
.
body {
  background: yellow;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="Table_01">
....
.....
</div>

To rectify this unexpected misalignment, adjusting the CSS property to top:64px might serve as a quick fix. However, it may lead to further misalignment issues on mobile devices.

This discrepancy seems to recur across all exported tables from Photoshop, and despite thorough research, no definitive solution has been found. The unique combination of Photoshop sliced tables with Bootstrap usage presents a challenge that I seem to tackle alone. Nonetheless, any insights or assistance would be greatly appreciated. Thank you.

Answer №1

When using Bootstrap, it modifies the line-height and font-size of the body element, causing issues with small images. This results in one line—including the image—appearing higher than the actual image itself.

To resolve this problem, you can set the line-height to zero on the container divs holding the images.

div.Table_01,
div.Table_02,
div.Table_03,
div.Table_04,
div.Table_05,
div.Table_06,
div.Table_07,
div.Table_08,
div.Table_09,
div.Table_10,
div.Table_11,
div.Table_12,
div.Table_13,
div.Table_14 {
  line-height: 0;
}

<!-- Additional CSS Styles -->

body {
  background: yellow;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="Table_01">
<!-- Add image elements here -->
</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

Why is my md-button in Angular Material displaying as full-width?

Just a quick question, I created a simple page to experiment with Angular Material. On medium-sized devices, there is a button that toggles the side navigation, but for some reason, it expands to full width. There's no CSS or Material directives causi ...

Is it possible to modify the CSS produced by Bootstrap in an Angular application?

Just starting out with Angular and Bootstrap I have the following displayed in my browser: Browser Code shown through inspect and this is what I have in my code: <ng-template #newSlaVmData let-modal> <div class="modal-header moda ...

"Utilizing Bootstrap's hamburger menu for a sleek solution when your menu becomes overcrowded

One interesting aspect of Bootstrap is its ability to collapse menu items into a hamburger menu within the navbar at specific window size breakpoints. However, there are instances where even on larger screens that exceed these breakpoints, the hamburger bu ...

Tips for creating an editable div that can also incorporate a textarea and the option to upload or delete photos

On my website, users can upload images, names, and descriptions which are saved in a MySQL database. The information is then fetched to display on the website. The code below allows users to enter this information and see it displayed when they click the s ...

Concentrate and essential

I am encountering an issue with required inputs and the :focus styling on those inputs. When I try to submit empty values, the red border from the required styling appears and does not disappear when I click on the input. As a result, I end up with a stran ...

What distinguishes line-height:1.5 from line-height:150% in CSS?

Does anyone have any information on this? ...

Formatting Text in CSS and HTML

I need help aligning three images horizontally with text underneath, using CSS. Despite trying multiple methods, the images remain vertically aligned and the text does not align properly with the images. #img_cont { display: table; width: 90%; ...

Chronological Overview (Highcharts)

Can you customize a timeline in Highcharts to resemble the image? https://i.sstatic.net/5Lipu.png I have a functional example of the timeline I desire, but the color coding and filtering aspects are challenging for me. I am attempting to apply a filter th ...

The Bootstrap row snag causing text display issues

There seems to be a glitch when the first column has more text than the one next to it. Check out the screenshot provided for reference. Any suggestions on how to fix this issue in Bootstrap? https://i.sstatic.net/fSq68.png Live Demo: https://jsfiddle. ...

The moving background is not remaining still

Hi everyone, I'm currently in the process of creating a new background design for my website and I want to add some animation to it. You can view my progress here: One issue I am facing is that the "background" div does not remain fixed when scrollin ...

Apply CSS styles to the checkbox

I am new to CSS and I need help styling a checkbox element. When the user selects one of the checkboxes, I want the background color to change to yellow. Thank you for any assistance you can provide! .radio_toggle { float:left; } .radio_toggle label ...

I've come across a challenge in my React PDF project where I am struggling to display the bottom and right margins, as well as the borders, in my reactPDF

I am currently working on creating a PDF using the @react-pdf/renderer library within my React project. Everything seems to be functioning correctly except for an issue with the right and bottom margins not appearing in the PDF. Strangely, the top and left ...

What is the best way to adjust the mobile screen size to display the most optimized version of a web app's

Currently, I am utilizing react, Bootstrap, and some custom sass to construct and style the front end of my web application. While the design appears good on mobile devices, there is an issue where users need to pinch the screen due to it looking slightly ...

Converting images to greyscale or transparency within a ReactJS component

I am exploring ways to transform an image into grayscale or make it transparent before using it as a background in ReactJS. Is there a way to achieve this in ReactJS? My current code snippet is shown below: <GridListTile> <img style={{ -we ...

Issue with CSS 3 gradient compatibility in Internet Explorer 8

My CSS3 gradient button is working perfectly on all browsers except for IE8. To make it work on IE8, I am utilizing CSS3 Pie. You can see the search button in action by visiting: Upon inspecting my console, I noticed an error on this line: PIE.htc, lin ...

Looking to preserve the "ALL" selection in a JavaScript-CSS filter?

On the front page, there are approximately 16 posts displayed along with a filter featuring 4 drop-down menus showcasing post categories. I have assigned category names as classes to each post div and am currently using javascript to hide them. The code s ...

Is setting the height to 100% a dependable option for container loading during the initial page rendering in CSS?

Upon arrival on the page, I envision the container containing the "search" to expand and occupy the entire screen. Seems simple enough: just set the height to 100%. If the user chooses to scroll down, they will see the rest of the content. It almost fee ...

Create a small circle in the bottom left corner with a constrained size

I'm trying to create a circle at the top of the screen on mobile, similar to the image below. The circle should take up a percentage of space, with the rest of the content appearing against a blue background as shown in the image. However, I'm h ...

Center the span element within Bootstrap 5 button groups

I am experiencing an issue where the span elements in my button groups are not aligning properly. I am looking for a way to align these span elements within the button groups without using fixed widths. Creating a basic web modal with Bootstrap 5 <di ...

place another ionic3 button adjacent to the existing one

I was looking to position a button next to another one, rather than below it <ion-row> <span *ngIf="dado.status == 0" style="margin-left: 50%"> Pending </span> ...