Tips for resizing the background image within a DIV element

HTML:

<div class="navImageLinks">
    <div id="fp" class="mainImageNav floatLeft fp">
        <img src="../theImages/FindaProvider_icon.png" width="20" height="20" style="vertical-align: middle;" /> Find a Provider
    </div>
    <div id="sv" class="mainImageNav floatLeft sv">
        <img src="../theImages/Services_icon.png" width="20" height="20" style="vertical-align: middle;" /> Services
    </div>
    <div id="lc" class="mainImageNav floatLeft lc">
        <img src="../theImages/Locations_icon.png" width="20" height="20" style="vertical-align: middle;" /> Locations
    </div>
    <div id="ma" class="mainImageNav floatLeft ma">
        <img src="../theImages/MakeAnAppt_icon.png" width="20" height="20" style="vertical-align: middle;" /> Make an Appointment
    </div>
</div>

CSS:

.navImageLinks
{
    width: 100%;
    overflow: hidden;
    padding: 0;
    margin: 0;
}
.mainImageNav
{
    width: 25%;
    height: 30px;
    line-height: 30px;
    vertical-align: middle;
    text-align: center;
    font-size: small;
    padding: 0;
    margin: 0;
    color: #FFF;
    font-family: Arial, Verdana;
    font-weight: bold;
}
.fp
{
    background: url('../theImages/FindaDoc_NotActive.png') no-repeat;
    background-size: 100% 100%;
    cursor: pointer;
}
.sv
{
    background: url('../theImages/Services_NotActive.png') no-repeat;
    background-size: 100% 100%;
    cursor: pointer;
}
.lc
{
    background: url('../theImages/Locations_NotActive.png') no-repeat;
    background-size: 100% 100%;
    cursor: pointer;
}
.ma
{
    background: url('../theImages/MakeAnAppt_NotActive.png') no-repeat;
    background-size: 100% 100%;
    cursor: pointer;
}

IE (zoomed out):

Firefox (zoomed out):

Is there a way to modify the CSS to ensure the background also stretches in IE?

Answer №1

To achieve this effect, we can utilize the cutting-edge CSS3 background size property.

 -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;

For Internet Explorer, cover backgrounds can be implemented with the following CSS properties.

filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='.myBackground.jpg', sizingMethod='scale');
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='myBackground.jpg', sizingMethod='scale')";

For more alternative methods, take a look at this insightful article: http://css-tricks.com/perfect-full-page-background-image/

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

Unable to load module/controller file from Angular 1 into view/html

var app = angular.module("appModule",[]); app.controller("viewController",function($scope){ $scope.greeting = "Welcome to the future"; }); <html> <head> <script src="Scripts/script.js"></script> <script ...

Error: jQuery is unable to access the property 'xxx' because it is undefined

While attempting to make a post request from the site to the server with user input data, I encountered an error message saying TypeError: Cannot read property 'vehicle' of undefined as the response. Here is the HTML and script data: <!DOCTY ...

Jquery's .text() and .html() methods seem to be malfunctioning

Utilizing a jQuery function: $("#btn1").click(function(){ $("p").text("") } Each time the button is clicked, the .text() field fails to load. When I modify the value of .text to a shorter string, it functions correctly. ...

Issues encountered when attempting to utilize removeEventListener() with multiple elements within a for loop in Javascript

After experimenting, I have been exploring ways to avoid encountering repeated event listeners The script provided below iterates through all buttons with a specific attribute. However, the issue is that it only functions effectively for a single button ...

How can I create a DIV element that consistently shows text when clicked?

Is there a way to achieve this effect using just CSS and HTML? When clicking on the question text, it should reveal the answer below, and clicking again should hide the answer. I have managed to make it work with hover, but I am unsure how to implement it ...

Leveraging the power of jQuery Validation in conjunction with Bootbox

I am currently facing an issue with integrating the jQuery validation plugin with bootbox.js (modals). The modal contains a form with fields that require validation. To showcase my problem, I have set up a jsFiddle here: http://jsfiddle.net/rDE2q/ Upon ...

Enhancing the appearance of multiple images with CSS and Bootstrap styling

I am struggling to arrange multiple images in my booking system as they are all displaying in a single column rather than the desired layout https://i.sstatic.net/1E8jO.png What I had hoped for was a layout like this https://i.sstatic.net/v8K34.jpg Curre ...

Ways to eliminate padding on narrow screens with bootstrap 5.2 features

I have a container with a padding of 5 (p-5) applied to it. However, I am looking for a way to automatically remove the padding when the screen size is small, without adding more CSS rules. Is there a solution using only bootstrap classes? <div class= ...

Ways to customize decoration in Material UI TextField

Struggling to adjust the default 14px padding-left applied by startAdornment in order to make the adornment occupy half of the TextField. Having trouble styling the startAdornment overall. Attempts to style the div itself have been partially successful, b ...

Click the button to instantly scroll to a particular word with highlighting, and with another click, jump to the next occurrence

In order to achieve the objective, simply click on a button that will search for and scroll to a specific word while highlighting it. The same button can be clicked again to find the next occurrence, and so on. If you need an example of how this works, ch ...

Adjust the class of a div element located close to its ancestor using JavaScript

I'm trying to change the class of the element #sidePanel from .compact to .expanded dynamically in this code snippet: <div id="sidePanel" class="compact"></div> <div id="topbar"> <div id="buttonContainer"> <div ...

The hover drop-down menu in CSS is not appearing in the correct position

Having trouble with my navigation bar - the dropdown menu isn't showing up below the category when I hover over it. It keeps ending up in the left-hand corner and I can't access it! I've searched everywhere for a solution, but can't fin ...

Creating an external JavaScript and CSS file for date picker in Eclipse can be done by following a few simple steps. By creating separate files for the

I am using the following javascript and css styles: <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" type="text/css" media="all" /> <script src="http://ajax.googleapis.com/ajax/libs/jq ...

Best practice for showcasing an MVC Form with the use of Bootstrap

I am facing an issue with my form layout while trying to capture user input. The use of Bootstrap is creating two columns for text boxes and their labels, but the alignment goes off track with the last EditorFor element. I'm questioning if I am misusi ...

Adjust mesh tessellation level using scroll control

On this page (), you can see how the meshes forming the text continuously come together and then separate in a loop, as demonstrated in the source code here: https://github.com/mrdoob/three.js/blob/dev/examples/webgl_modifier_tessellation.html. I am inter ...

Ensuring validation with Javascript upon submitting a form

Hey there, I'm looking to validate field values before submitting a form. Here's the code I have: <table width="600" border="0" align="left"> <tr> <script type="text/javascript"> function previewPrint() { var RegNumber = docum ...

Is it possible to consistently show the placeholder in mat-select regardless of the item currently selected?

I am looking to keep the mat-select element displaying the placeholder at all times, even if an option has been selected. Below is my HTML code: <mat-select [formControlName]="'language'" placeholder="Language"> <mat-option value=" ...

I require the use of XSL to verify the href value of links and modify it if needed, without altering any other attributes

The code mentioned above performs the following tasks: Locates links Checks if it is a fully pathed link or an email link If yes, no action is taken. If no, it checks for a # to determine if it is an anchor If yes, no action is taken. If no, it adds the d ...

When using jQuery and AJAX together, it seems that the POST method is returning

Currently experimenting with Cloud9. The current project involves creating an image gallery. On the initial page: There are a few pictures representing various "categories". Clicking on one of these will take you to the next page showcasing albums fro ...

Tips for adding a class to the output of a jQuery ajax request?

I've been searching for a solution to this issue without any luck. Below is the code I have: jQuery("#categories_parent_id").change(function() { id = jQuery("#categories_parent_id").val(); jQuery.ajax({ type: ...