"Optimizing background positioning for IE9 in right-to

Snippet: http://jsfiddle.net/bHRVe/

An arrow sprite is utilized, and the background position appears correctly in Firefox and IE8:

Nevertheless, when switching to RTL direction, IE9 seems to be causing issues as the arrow disappears:

If I adjust the positioning from left -52px to right -52px, it solves the problem in IE9 but introduces new issues in other browsers.

Is there a solution that resolves this using the same CSS without resorting to conditionals or hacks?

Answer №1

Here is a simple solution using pure CSS to solve your issue:

CSS:

.button span {
    background: url("http://i48.tinypic.com/16716yb.png") no-repeat 0 -52px;
    margin-right: 0.5em;
    padding: 0 5px;
    direction: rtl;
    width:4px;
    height:15px;
    display:inline-block;
} 

HTML:

Note: It's recommended to include a space ( ) in empty elements as it can help with browser compatibility.

<a class="button" href="#">
    <b>تم, غزو عل جنوب</b>
    <br/>
    <u>ب ان. Testما وص</u>
    <span>&nbsp;</span>
</a>

Additional Note: By default, <span> and <a> elements are inline elements. Depending on our needs, we may need to use display:block; or display:inline-block; with CSS.

In this case, you could also use display:block;, but then you'd need to add float:left to ensure the span appears correctly.

Screen Shot: IE9

Answer №2

Modify your CSS slightly:

.button span {
    background: url("http://i48.tinypic.com/16716yb.png") no-repeat scroll left -52px transparent;
    margin-right: 0.5em;
    direction: rtl;
    display: inline-block;
    width: 10px;
    height: 16px;
}

See it in action here. Tested and proven to work on IE9, Chrome, Firefox, Safari, and Opera :)

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

Enhancing Speed and Efficiency with Now ui kit CSS Framework

Recently, I switched over to the stunning Now-UI kit which is built on Bootstrap 4.0. While Bootstrap has always been highly responsive on all devices, I am currently facing an issue with the responsiveness of the Now-UI kit on mobile devices. If you cou ...

The standard jQuery Mobile CSS styling does not seem to be working across various browsers, extensive testing has been conducted

I'm currently experimenting with jQuery Mobile to enhance my skills, but I'm facing issues with applying the basic CSS styling. I have included the css link from the jQuery Mobile website and ensured that I am connected to the internet. However, ...

Create another div for the remaining vertical space occupied by the sibling div?

I currently have 3 different divs nested within each other: <div class="a"> <div class="b"> </div> <div class="c"> </div> </div> Here is the current CSS styling applied to these divs: .a { hei ...

Discovering the Perfect Color Combinations

Current Admin Panel Themes /** Custom Portlet Color Options **/ .Vibrant-Pink { background: rgb(220, 79, 173); } .Rich-Red { background: rgb(172, 25, 61); } .Bold-Orange { background: rgb(210, 71, 38); } ...

How to Toggle the Submit Button Using jQuery

I have implemented a feature using jQuery to disable the submit button and display a loading image. Here is how I have set it up: The HTML structure for the submit button looks like this: <div id="registerbtn" name="registerbtn"> <input typ ...

Utilizing a div element for creating a clipping mask with CSS

I am facing a challenge with a background image that has been set to background-size:cover; and a series of overlaid divs that I would like to convert into separate clipping masks. I have explored the clip: rect(20px, 20px, 20px, 20px,) feature, but since ...

The onClick event listener is not being recognized when using ReactDOMServer.renderToString

I am attempting to replicate the functionality of this fiddle: http://jsfiddle.net/jhudson8/135oo6f8/ (I also tried this example http://codepen.io/adamaoc/pen/wBGGQv and encountered the same issue with the onClick handler) My goal is to make the fiddle c ...

Live Server in VS Code not refreshing automatically as expected

My problem is with VS Code and Live Server for HTML CSS. I expected the page to automatically reload after editing my HTML, but that's not happening. Even though I have Auto-Save enabled, Live Server isn't updating or refreshing my page automati ...

Distinguishing between a video or image when uploading files in JavaScript

I've been researching whether JavaScript can determine if a file is a video or an image. However, most of the information I found only shows how to accept these types using the input tag. What I really need is for JS to identify the file type and the ...

The color scheme detection feature for matching media is malfunctioning on Safari

As I strive to incorporate a Dark Mode feature based on the user's system preferences, I utilize the @media query prefers-color-scheme: dark. While this approach is effective, I also find it necessary to conduct additional checks using JavaScript. de ...

Select the small image to reveal the larger overlay image

I have a grid of images and I want each image to expand into fullscreen when clicked. However, the JavaScript I am using is causing only the last image in the grid to overlay. How can I resolve this issue? Here is the code I am currently using: http://js ...

Ways to eliminate the blue selection box when dragging canvas objects in fabric framework

I've been trying to find a solution to remove the annoying blue highlight box that appears when dragging on the canvas while using fabric js, but so far I haven't had any luck. I've tried the following code, but it only works for text and n ...

The background-color of a single child within an absolutely positioned element in Chrome may not be displayed if the element has a z-index and overflow scrolling

This test page has been created to showcase the issue: <html> <head> <style> .panel { position: absolute; width: 326px; max-height: 200px; overflow: scroll; z-index: 1000; } .item-container { width: 100%; list-style: none; ...

What is the best way to make the contents of my table scroll while keeping the table structure fixed?

I am looking for a way to scroll the contents of my table horizontally while keeping the table structure fixed. Currently, when I try to scroll, the table structure scrolls along with the content, resulting in visibility issues at both ends due to the corn ...

What is the best way to prevent a single cell within a table from hovering?

Within a table cell, I have another table. The outer table has a hover effect applied to it, but I want to prevent the inner table with the id "table_I_don_not_want_to_hover" from inheriting this hover behavior like the rest of the cells and rows. I need t ...

Tips for relocating a CSS button

I have designed two buttons using css and I am looking to align them below the title "forecast customer activity". Due to extensive styling in css, the code might appear lengthy. Requesting assistance with a solution after reviewing the following code snip ...

In Vue, it is not accurate to measure overflow

I am working on creating an overflow effect with tagging that fades out at the beginning to provide a subtle hint to users that there is more content. Here is what it currently looks like: https://i.stack.imgur.com/fXGBR.png To achieve this, I added a fa ...

Issue with background in list items

I am struggling with aligning the background of my vertical menu to the right and center from the top. Here is the code I have tried: ul.nav { margin:0; background-position:center; background-image: url(../images/nav_bg.gif);font-family: "Century Go ...

Emphasize any word starting with an @ symbol to highlight its importance

My goal is to enhance the appearance of words that begin with an "@" symbol by making them bold. For example, transforming the sentence: '@xyzharris has a cat @zynPeter' into: '@xyzHarris has a cat @zynPeter' ...

Using jQuery trigger to activate a function whenever a new <li> element is appended to a <ul> list

I am currently facing an issue with a PHP page that utilizes flush() and ob_flush() to send progress updates to a browser. The page generates a styled <ul class="progresslog"> where individual <li class="{success|warning|error}"> items are sent ...