difficulty arises when attempting to display background-position in android

My CSS includes the following:

.flag
{

    background-image: url('http://192.168.1.88/david/images/flag_set/flag_set/europa_flag_set.jpg');
    width: calc(4 * 5.93px);
    height: calc(4 * 3.99px);
    background-size: calc(4 * 35.08px) calc(4 * 49.63px);
    cursor:pointer;

}
.flag.portugal
{
    float: left;
    background-position: calc(4 * -14.62px) calc(4 * -30.42px);
}
.flag.reinoUnido
{
    float: right;
    background-position: calc(4 * -21.40px) calc(4 * -40.22px);
}

Accompanied by the corresponding HTML:

<div class="flag contentor">
    <div class="flag portugal" onclick="$('.lang').removeClass('mostra');$('.lang.portugal').addClass('mostra');"></div>
<div class="flag reinoUnido" onclick="$('.lang').removeClass('mostra');$('.lang.reinoUnido').addClass('mostra');"></div>
</div>

While this works flawlessly on my laptop, my android tablet only displays two white squares.

Could it be an issue with how I am positioning the background? Or perhaps a browser incompatibility with the tablet?

The image I am using can be found here:

https://i.sstatic.net/YLTDm.jpg

What I intend to display in the divs are the flags of Portugal and the United Kingdom as shown in this example:

https://i.sstatic.net/cNeyT.png

Is there a polyfill or shim available that could help me rectify this issue?

Answer №1

calc() is typically used for conducting calculations with different units, such as 100% - 24px, 15em * 14%, and so on. If you already have precise measurements, using calc may not be necessary. This could potentially be the issue at hand. It appears that your background-image declaration is correct within your code. However, setting pixel sizes to two decimal places seems unnecessary and illogical to me.

.flag
{
    background-image: url('http://192.168.1.88/david/images/flag_set');
    width: 23.72px;
    height: 15.96px;
    background-size: 140.32px  198.52px;
    cursor:pointer;

}
.flag.portugal
{
    float: left;
    background-position: -58.48px -121.68px;
}
.flag.reinoUnido
{
    float: right;
    background-position: -85.6px  -160.88px;
}

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

Steps to create full screen jQuery tabs with overflow scroll feature in the content

I am in the process of creating a responsive web design using jQuery tabs. My goal is to make one page of the website occupy the entire screen (100% height and width), have a fixed height for the div.ui-tabs-nav, and enable scrolling for the content of div ...

Flex-wrap functionality in versions of Safari 6 and earlier

As I work on developing my website, I have been using flexbox to assist with the layout. It has been functioning well on most browsers, but I have encountered issues with Safari versions below 6.1. Specifically, I am struggling with flex-wrap as I want the ...

The best approach to incorporating interactive animation in next.js

My vision is to develop a character creation application using next js. The app should empower users to customize the character using sliders and gender selection buttons. The ultimate goal is to have a 2D animated version of the character that dynamicall ...

css styles for URLs that are sensitive to letter case

I'm currently at a loss for solutions as I can't seem to pinpoint the reason behind this peculiar behavior. I'm using Orchard CMS 1.4 along with a customized superfish stylesheet. Interestingly, the behavior varies depending on how the site ...

Inconsistency in retrieving and setting width values with jQuery across various web browsers

My TH element currently has both left and right padding set to 18px. I am attempting to determine its width using jQuery, convert this width from pixels to a percentage, and then set the element's width based on this calculated percentage. var origin ...

Tips for formatting dt and dd elements side by side on one line

How can I use CSS to style the following content in two columns: <dl> <dt>Mercury</dt> <dd>Mercury (0.4 AU from the Sun) is the closest planet to the Sun and the smallest planet.</dd> <dt>Venus</dt> ...

As the window width decreases, the image is breaking free from its container

When the window is in full screen, such as lg or md, the content fits within the container. However, when I resize the window to be smaller, the image overflows outside of the container. This layout was created using Bootstrap 3. Below is the HTML and CSS ...

Navigating through the website has become quite challenging due to the malfunctioning navigation bar. Instead

I recently completed a website and designed an awesome navigation bar in a separate file. However, when I combined them together, the navigation bar disappeared. The background of my "list" div should be filled in and larger, but it's not working as e ...

Assistance needed with CSS selectors for implementing with selenium

<div id="footerSearchInputDefault" class="defaultText" style="visibility: hidden;">Search myTwonky</div> In relation to selenium, what do the following terms refer to in the above code snippet? attribute element value text label I often fin ...

Problem involving the h1 tag nested within a div container

I have two files, one in .html format and the other in .css format. Here is a snippet of their content: #left, #right { display: inline-block; } #left { width: 15%; height: 550px; margin-bottom: 100px; margin-left: 10px; border: 1px solid bl ...

Setting the Height of a Fixed Element to Extend to the Bottom of the Browser Window

I currently have a webpage layout featuring a header at the top, a fixed sidebar on the left side, and main content displayed on the right. A demo version of this layout can be viewed at http://jsbin.com/iqibew/3. The challenge I'm facing is ensuring ...

Troubleshooting: Issue with Bootstrap 4's container-fluid not functioning as

I recently started learning Bootstrap 4 through a Udemy tutorial but I'm having trouble with the container-fluid class. Despite my efforts, the container doesn't stretch to full width as intended. Here is the code I'm working with: <!doc ...

When my webpage is opened in Firefox, I notice that it automatically scrolls down upon loading

I recently embarked on the task of building a website from scratch but ran into an unusual bug in Firefox. The issue causes the page to scroll down to the first div, completely bypassing its margin. I want to clarify that I am not seeking a solution spe ...

Giving 100% height to the parent element without specifying a specific height

Struggling with some height adjustments while working on my CSS using HTML5 and CSS3. HTML 1. <section> 2. <article> 3. Article 1 4. </article> 5. <article> 6. Article 2 7. </article> 8. ...

The placement of my footer is off and not aligned with the bottom of the page

I am struggling to make my footer align with the bottom of the page rather than sticking to the bottom of the browser window and moving along with the scroll. How can I fix this issue? The goal is to have the footer remain out of sight at the bottom of th ...

Div encountering CSS glitches

Is there a way to position the c div at the bottom of the a? Trying out Position:relative doesn't seem to do the trick. Check out the DEMO here ...

Tips for building a modal box with HTML, CSS, and jquery!

Looking to create a modal box using HTML, CSS, and jQuery? <button id="myBtn">Click here to open the Modal</button> This code will help you achieve that: <!-- This is the Modal content --> <div class="modal-content"> <sp ...

What are the steps to create a dynamic navigation bar in React without encountering hydration issues?

My goal is to dynamically show or hide links based on user authorization. Here's my initial approach: const Navbar = () => { const { canDo, ...} = useUser(); //A Zustand store return ( <> <div> <ul> ...

Issues with the styling of HTML code

Our website features a main menu with submenus that are intended to be displayed only when hovering over the main menu. However, upon loading the site, the submenu is already visible causing an issue. We need the submenu to appear only when the main menu i ...

What is the method for adjusting the subheader color on a Material UI card component?

How can I change the subheader text color to white in a Material UI Card with a dark background? Here is my code: const useStyles = makeStyles(theme => ({ menuColor: { backgroundColor: theme.palette.primary.main, color: '#ffffff', ...