CSS media query does not ensure that images will always fill the container to 100% width

I am currently facing an issue where my images are not displaying at 100% width within a container when I have a wide screen. Instead, there are spaces between the images. How can I fix this problem?

See below for the code:

<div class="container-responsive">


<footer>
<div class="row no-gutter">
  <div class="col-md-4 col-sm-12 col-lg-4 no-padding">
    <a href="#"><img src="images/but-plan.png" alt="Plan" /></a>
  </div>
  <div class="col-md-4 col-sm-12 col-lg-4 no-padding">
    <a href="#"><img src="images/but-administration.png" alt="Administration" /></a>
  </div>
  <div class="col-md-4 col-sm-12 col-lg-4 no-padding">
    <a href="#"><img src="images/but-our-team.png" alt="Our Team" /></a>
  </div>
</div>
</footer>

</div> <!-- container -->

CSS

footer a {
  display:block;
}

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

/*******************************************************/
/******************* Helper Classes ********************/
/*******************************************************/

.no-padding {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

Answer №1

To adjust the size of your image, you can modify the CSS code by changing max-width to width:

footer img {
  width:100%; 
  height:auto; 
}

Answer №2

Consider changing the image width to 100% instead of using max-width.

Answer №3

To ensure your image takes up 100% of the container width, be mindful of potential pixelation issues that may arise from stretching the image. One workaround is to use a larger image (although this can impact performance) or implement srcset.

footer a {
  display:block;
}

footer img {
  width:100%; 
  height:auto; 
}

/*******************************************************/
/******************* Helper Classes ********************/
/*******************************************************/

.no-padding {
    padding-left: 0 !important;
    padding-right: 0 !important;
}
<div class="container-responsive">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<footer>
<div class="row no-gutter">
  <div class="col-md-4 col-sm-12 col-lg-4 no-padding">
    <a href="#"><img src="http://via.placeholder.com/150x150" alt="Plan" /></a>
  </div>
  <div class="col-md-4 col-sm-12 col-lg-4 no-padding">
    <a href="#"><img src="http://via.placeholder.com/150x150" alt="Plan" /></a>
  </div>
  <div class="col-md-4 col-sm-12 col-lg-4 no-padding">
    <a href="#"><img src="http://via.placeholder.com/150x150" alt="Plan" /></a>
  </div>
</div>
</footer>

</div> <!-- container -->

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

The feature to disable legend click in Chart.js does not activate unless the specific condition is met

I am working with chartjs and have encountered a scenario where I need to disable actions when a legend item is clicked, but only under certain conditions. I was able to accomplish this using the following code snippet: legend: { position: 'right& ...

The exterior DIV does not conform to shrinking dimensions

I've set the display property to inline-block, but the htmlDiv div in this code snippet is not behaving as expected. It's acting as though the inner divs are next to each other even when they're not. How can I fix this? If it's unclear ...

What is the best way to continuously loop an image from left to right and right to left indefinitely using JavaScript?

As part of the challenge, I am tasked with creating a Pacman game using HTML, CSS, and JavaScript. One key aspect is to control the movement of the ghosts throughout the game. However, I am facing an issue with the current function that controls the ghost& ...

Creating a mobile/tablet friendly menu design

I'm currently working on designing a menu. I have made it look pretty nice so far, but I am facing an issue when the menu is viewed on mobile or small tablets. I want the menu to disappear and be replaced by a "MENU" button instead. Does anyone have ...

The CSS property input::-webkit-outer-spin-button adjusts the margin-left and is exclusively visible in Chrome browser

Strange things are happening... Let me share the code for my inputs: #sign_in input#submit { height: 56px; background-color: #88b805; font-weight: bold; text-decoration: none; padding: 5px 40px 5px 40px; /* top, right, bottom, left ...

Unique styles and scripts for a custom login portal

Just beginning with angularjs and diving into a project. Using ui.router for handling various views. Encountering an issue where I have a main page index.html, all my views load in <div ui-view=""></div>. But what if I want to incorporate a log ...

Collapse a previously used item when a new item is opened within Angular

I've managed to create a tree structure for a sideBar Menu using this code, and it's working well. However, what I'm trying to achieve is that when a menu with submenus is expanded and the user clicks on another parent menu, the expanded sub ...

Looking for assistance with changing the class of a span when a radio button is selected

I'm facing an issue with toggling the class of a <span> when a radio button is clicked. <html> <head></head> <style type="text/css"> .eHide { display:none; } </style> <script type="text/javas ...

The alignment of the table appears off on Internet Explorer, while it is perfectly centered on all other web

I'm encountering a strange issue with my table alignment on Internet Explorer. The table is offset to the right in IE, but perfectly centered in other browsers like Edge, Firefox, and mobile browsers. I am using Bootstrap for my design, but haven&apos ...

Switch the background image in a table data cell using ngIf in Angular

Can you help me with this: I have a td in a table with a background image applied <td background="assets/images/crew/sign.jpg" style="background-repeat: no-repeat; background-size: contain; background-position: center center"> W ...

The new version 5.1 of Bootstrap modal does not disable scrolling on the <body> element

I'm currently working on a project in Angular 11 using Bootstrap (v5.1.3). My main goal is to create a functionality where clicking on a card, similar to a blog post, will trigger a Bootstrap modal popup displaying the content of that specific post. B ...

My Drop Down menu is not displaying the <a> in two lines, and I'm having trouble getting it to show correctly

Hello there! I've encountered an issue with my drop-down menu. The text within the <a> tags is too long to fit on a single line, and I'm struggling to make it display in two lines instead. I've been experimenting for the past couple o ...

What's the best way to ensure that a div remains fixed at the top of the page while also being centered?

I have a div that I've centered using margin left and right auto. However, I want this bar to be visible throughout my page, so I positioned it absolutely. But now the bar is not centered anymore, it's appearing on the left. How can I position th ...

Building a Navigation Menu in Vue.JS Using Bootstrap Styles

Greetings! I had previously developed a Menu for my Vue 2 project. Upon creating a new Vue 2 project (with plans to migrate to Vue3), I proceeded to import my Menu, which consists of HTML and CSS. Unfortunately, it seems that the implementation is not wor ...

Chrome distorts the display:table when zoomed in

Consider this CSS snippet: .table { display:table; } .table-row { display: table-row; } .table-cell { display: table-cell; } Now, let's add some HTML to go along with it: <div class="table"> <div class="table-row"> ...

The Bootstrap form input control is not updating its background and border color as expected

Recently, I decided to revamp the look of the input controls on my website. I made some changes in the code like so: //Updating bootstrap variables $input-bg: $background-color; $input-color: yellow; $input-border-color: $gray-500; $input-focus-border-colo ...

Utilize JavaScript to append a CSS class to a dynamic unordered list item anchor element

I am working with a list of ul li in a div where I need to dynamically add CSS classes based on the click event of an anchor tag. Below is the HTML structure of the ul li elements: <div class="tabs1"> <ul> <li class="active"> ...

Understanding MUI5 prop handling

Recently, I decided to experiment with Material UI 5 sx props just for fun. I encountered a bit of confusion while trying to replicate the behavior of the previous MUI 4 makeStyles function. Specifically, I was attempting to pass JSS classnames to sx props ...

Avoid auto-scaling of div content

I need the .content within the main container .box to resize proportionally to match the width of the .box exactly, without being smaller. .box { width: 95%; background-color: red; padding: 20px; text-align: center; margin: 55px auto 40px; } . ...

Clean up your CSS code in Firefox 10.0.X with this amazing cleaner

Searching for a tool to clean up CSS in Firefox 10.0.x similar to Dust-Me Selectors. Unfortunately, Dust-Me Selectors is currently not supported in Firefox 10.0.x. Any recommendations for an online tool to identify unused CSS selectors? ...