Auto resizing images with Bootstrap may not function correctly when placed in the left column

I have a standard 3-column layout with similar images in the left and right columns. When I resize the page, the right image becomes smaller but the left image does not. This causes the middle container to overflow past the left image.

Here is the CSS for image resizing:

   img {
      display: block;
      max-width: 100%;
      height: auto;
    }

Here is a snippet of my full code:

<!doctype html>
<html lang="en>
<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Title</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <style>
    .logo_item {
      display: inline-block;
      margin-left: 2.5em;
      margin-right: 2.5em;
    }
    img {
      display: block;
      max-width: 100%;
      height: auto;
    }
  </style>
</head>
<body>
  <div class="container-fluid">
    <!-- 2nd row -->
    <div class="row mt-4">
      <div class="brd_black col">
        <div style="position:fixed;">
          <a href="javascript:window.history.back();"><img src="https://v1.iconsearch.ru/uploads/icons/crystalclear/64x64/folder_home.png" /></a></div>
      </div>
      <div class="brd_black col-10">
        <div class="row">
          <div class="brd_black col-12 bg-white align-top brd_grey pb-3 pt-3 text-center">
            (Lorem Ipsum text here)
          </div>
        </div>
      </div>
      <div class="brd_black col">
        <div style="position:fixed;">
          <a href="faq.html"><img src="https://v1.iconsearch.ru/uploads/icons/crystalclear/64x64/folder_home.png" target="_blank" /></a></div>
      </div>
    </div>
  </div>
  </div>
</body>
</html>

But why is this happening?

Answer №1

<!doctype html>
<html lang="en">
<head>
  <!-- Necessary meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Page Title</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <style>
    .logo_item {
      display: inline-block;
      margin-left: 2.5em;
      margin-right: 2.5em;
    }
    img {
      display: block;
      max-width: 100%;
      height: auto;
    }
    .bg_img
    {
      background: url('https://v1.iconsearch.ru/uploads/icons/crystalclear/64x64/folder_home.png')no-repeat center center;
      display: block;
      width: 20px;
      height: 20px;
      background-size: contain;
      float: left;
      position: fixed;
    }
  </style>
</head>
<body>
  <div class="container-fluid">
    <!-- 2nd row -->
    <div class="row mt-4">
      <div class="brd_black col">
        <div>
          <a href="javascript:window.history.back();" class="bg_img"></a>
        </div>
      </div>
      <div class="brd_black col-10">
        <div class="row">
          <div class="brd_black col-12 bg-white align-top brd_grey pb-3 pt-3 text-center">
            Placeholder text for a web page goes here.
          </div>
        </div>
      </div>
      <div class="brd_black col">
        <div>
          <a href="faq.html" class="bg_img"></a>
        </div>
      </div>
    </div>
  </div>
  </div>
</body>
</html>

Answer №2

Eliminate the position:fixed styling from the div.
After testing your code, I removed the styling for your img tag and replaced it with the default img-fluid class from bootstrap-4, which resulted in fantastic performance.

    <!doctype html>
<html lang="en">
<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Title</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  <style>
    .logo_item {
      display: inline-block;
      margin-left: 2.5em;
      margin-right: 2.5em;
    }

    .sticky {
      position: sticky;
      position: -webkit-sticky !important;
      top: 0;
      right: 0;
      left: 0;
      z-index: 1030;
      display: flex;
    }

    .stick_img{
      position: sticky;
      position: -webkit-sticky !important;
      top: 15px;

    }

  </style>
</head>
<body>
  <div class="container-fluid">
    <!-- 2nd row -->
    <div class="row mt-4">
      <div class="brd_black col sticky">
        <div>
          <a href="javascript:window.history.back();"><img src="https://v1.iconsearch.ru/uploads/icons/crystalclear/64x64/folder_home.png" class="img-fluid stick_img" /></a></div>
      </div>
      <div class="brd_black col-10">
        <div class="row">
          <div class="brd_black col-12 bg-white align-top brd_grey pb-3 pt-3 text-center">
            INSERT UNIQUE TEXT HERE
          </div>
        </div>
      </div>
      <div class="brd_black col sticky">
        <div>
          <a href="faq.html"><img src="https://v1.iconsearch.ru/uploads/icons/crystalclear/64x64/folder_home.png" target="_blank" class="img-fluid stick_img" /></a></div>
      </div>
    </div>
  </div>
  </div>
</body>
</html>

Give this revised code a try, it should function smoothly

Answer №3

It is recommended to eliminate the position:fixed; CSS property from your code snippet.

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 your logo and personalized graphic to the top header section of your website using the Divi Wordpress theme

Can a logo and custom graphic be placed in the "top-header" section (i.e. to the left of the phone number) within the well-known ElegentThemes Divi template? I experimented with absolute positioning and adjusting the container/body to relative. The code c ...

Making poll everywhere items align horizontally using HTML: a step-by-step guide

Is there a way to display two different Poll Everywhere polls side by side on a Blackboard course, rather than having them stacked on top of each other? I have the embed codes for both polls ready to go. ...

Display an image when the cursor hovers over a text

I'm attempting to display an image when hovering over specific text. The image should not replace the text, but appear in a different location. The concept is as follows: When hovering over the word "Google", the Google logo should appear in the red ...

What is the best method to extend my borders to the very edge?

Struggling with table borders extending to the edge on a website using master pages and CSS stylesheet. This issue requires some troubleshooting, so any help would be appreciated. The problematic website is here. I need the border under the banner menu to ...

What are the steps to configure Bootstrap for optimal performance?

Here is the code snippet: <template lang="pug"> b-container b-row b-col h1 strong LICOTA® — ПРОФЕССИОНАЛЬНЫЙ ИНСТРУМЕНТ ВЫСШЕГО КЛАССА ДЛЯ АВТОСЕРВИСОВ И ПРОМ ...

Loading Images in Advance with jQuery, Native JavaScript, and CSS

After successfully implementing a method to hover on a small image and load an additional image to the right side of the page, I am now looking to enhance user experience by preloading images. Is there a way to preload an image using JQuery, allowing it t ...

The navigation bar is positioned with white space above it

Currently working on a website design and facing an issue with adding a clickable button to the Nav-bar. Noticed some white-space above the Nav-bar which is not desired. I had previously posted a similar question but unable to identify the CSS error causi ...

The background image does not appear to be displaying correctly on GitHub pages

I've encountered an issue where my svgs are not displaying as background-image or background on GitHub pages, even though they work fine locally. I utilized sass as a preprocessor for css, in case that detail is helpful. If anyone has insights on how ...

Having issues with Bootstrap customization in an Angular 7 project

I am currently working on customizing a Bootstrap 4 theme within an Angular 7 project. After installing Bootstrap, I updated my angular .json file to include the following: "styles": [ "./node_modules/@angular/material/prebuilt-themes/de ...

Having trouble getting CSS animation to work on Mozilla using mozAnimationName?

<style> @keyframes shake { 0% { -moz-transform:scale(0);opacity:0; } 25% { -moz-transform:scale(1.3);opacity:1; } 50% { -moz-transform:scale(0.7);opacity:1; } 75% { -moz-transform:scale(2); ...

The ease of use and availability of radio buttons

When clicking on the first or second value of the radio button, it selects the first option. Here is the HTML code: @supports(-webkit-appearance: none) or (-moz-appearance: none) { input[type='radio'], input[type='checkbox'] { ...

Tips on including a trash can symbol to rows in a bootstrap table using React

I am working on a table that contains various fields, and I want to add a trash icon to each row so that when it is clicked, the specific row is deleted. However, I am encountering an issue where the trash icon is not showing up on the row and I am unable ...

Twitter Bootstrap 3.3.5 navigation menu with a drop-down feature aligned to the right

I've been attempting to position the drop-down menu all the way to the right, following the search input field and submit button. I've tried using pull-right and navbar-right classes without success. Is there a method to accomplish this? <na ...

Changing the background color to white causes the progress bar line to become indiscernible

Here's how my form appears: https://i.sstatic.net/jXCxm.jpg Once I set the container to be: <div class="container" style="background:white;"> https://i.sstatic.net/DZjAK.png I want to make it white and ensure that the prog ...

Changing CSS styles dynamically using PHP

After stumbling upon a customizer live preview layout picker, I have finally found what I've been searching for – a live layout changer for WordPress. This solution works like a charm, but I'm wondering if there is a more efficient way to write ...

Tips for making a div with a single triangular side using Reactjs

Hey there, I'm looking to design a header similar to the one shown in this image. Can someone provide guidance on how I can achieve this UI using React.js? https://i.sstatic.net/zmW5x.jpg ...

Steps to showcase a form on a webpage using a button

My webpage features an HTML table with a table navigation bar that allows users to add items or inventory. However, when the "add item" button is clicked, a form appears below the table instead of on top of it. I want the form to display itself right on to ...

Troubleshooting a Dynamic Navigation Bar Problem with jQuery Integration

Having developed a responsive navbar, an issue arises during iPad breakpoints where attempting to close the active navbar by clicking the hamburger icon triggers the jQuery script to also perform .removeClass(".active").slideToggle() on two buttons, causin ...

Arrange the side by side display of uploaded image previews

Could someone please assist me with aligning my image upload preview in a row, similar to a brand/partners slider? The current preview output is not displaying as desired. Here is the code I have: <div class="image-gallery"> <div class ...

What is the best way to center align an element while having another element situated directly below it?

I want to create a grid of "clock" elements, with five clocks in each row. Below each clock, I'd like to display the DAY and DATE centered with the clock (day on top line, date below). Since I'm new to html/css, I appreciate your patience. Here&a ...