Tips for using Media Queries on smaller screens of Android devices

I've been working on a project with PhoneGap where I added a swipe view feature. For the background of the text, I used an image that is sized around 304 * 250.

Everything was running smoothly on screen sizes of 320 * 480 and 720 * 1280.

However, when I tried to test it on screens with sizes of 240 * 320 and 480 * 800, neither the background images nor the data value showed up.

To address this issue:

I decided to use a box shadow instead of the image. After implementing this change and testing it on a screen size of 320 * 480, it worked perfectly.

I then attempted to test it on screen sizes of 240 * 320 and 480 * 800 using Media Query.

While referencing a guide from here, I tried to implement it but faced difficulties in doing so.

This is my standard CSS:

.container
{
    width:80%; height:auto; margin-left:10px; margin-right:10px; background-color:#CCCCCC; text-align:justify; border-radius:20px; box-shadow: 10px 10px 5px #888888; padding:10px; min-height:250px;
}

My Media Query CSS:

@media only screen and (max-device-width: 240px) 
{
    .container
    {
       width:180px; height:150px; margin-left:10px; margin-right:10px; background-color:#CCCCCC; border-radius:20px; box-shadow: 10px 10px 5px #888888; padding:10px; ;
    }
}

I included the CSS file like this:

<link rel="stylesheet" type="text/css" href="css/common_set.css" />

The problem: Despite my efforts, the implementation did not work as expected. The box didn't appear, leaving me with just an empty screen.

Is there something wrong with how I approached this?

Answer №1

I'm not sure if this was intentional in your app, but you appear to have two semi-colons at the end of your CSS code snippet

@media only screen and (max-device-width: 240px) 
{
   .container
   {
      width:180px; height:150px; margin-left:10px; margin-right:10px; background-color:#CCCCCC; border-radius:20px; box-shadow: 10px 10px 5px #888888; padding:10px; **;**
   }
}

Answer №2

To begin, make sure to insert this meta tag into your HTML document.

<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />

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

What is the method for inserting line breaks in Django at particular characters?

How can I add line breaks after specific characters in my text? Check out this image: https://i.sstatic.net/bz1h1.png I need to insert line breaks after every 50 characters in the text shown in the image. Take a look at my HTML FILE: {% extends ' ...

The absence of libproject in Google Play services (Rev. 30) cannot be found within Eclipse Juno

After updating Google Play services, I encountered a problem where I could not find any libproject within it. When I cleaned the project, my apk file turned into a jar file. Upon further inspection, I realized that there was no libproject available to add ...

I have made various attempts, but can someone please point out the issue with this array?

I've been working on creating a random quote generator that generates a new quote whenever a button is clicked. However, I seem to have everything set up correctly but for some reason, when the button is clicked nothing happens. Below is the code I h ...

What is the best way to align my HTML column using CSS?

I'm currently working on my high school project and as a beginner, I am facing difficulties with formatting a column to display my bio. I want it to look like the example below: However, I am struggling to achieve this using my HTML and CSS code. He ...

Mastering the use of getSelectionStart and getSelectionEnd in EditText to enhance user interaction

I am curious about the technique that could allow me to determine if a user is selecting text in an edittext field. I plan on utilizing getSelectionStart and getSelectionEnd methods to accomplish my specific task. ...

Developing a standard JSON parsing function for handling in AsyncTask

As I work on creating an app that relies heavily on remote JSON calls to fetch and utilize data within the application, I've encountered a problem. The current function I'm using to retrieve JSON data from a URL and parse it causes the app to fr ...

Iframe vs. Viewport: A Comparison

Greetings from Brazil! I previously reached out to this forum in Portuguese, but unfortunately, I was unable to resolve my issue. I hope my English isn't too bad. After extensive research, I managed to create my HP using an Iframe. My knowledge of HT ...

Interactive JavaScript function designed to react to user commands

Struggling to develop a JavaScript/AngularJS function that notifies the user whether a entered number is too high or low (> 100 indicates it's too high)? Check out the HTML code below: <div> <p id="num">Number : <input type="nu ...

In terms of performance, is it better to fetch JSON data and render it using JavaScript, or to request the full

Similar Inquiry: Why is it a bad practice to return generated HTML instead of JSON? Or is it? When making an AJAX request to a PHP file, which method would result in quicker HTML rendering? Directly sending fully formatted HTML from PHP, Or sending ...

Implementing JQuery techniques to dynamically insert separate content into elements sharing the same class

I have utilized django to establish a model company featuring attributes like name and address. I aim to exhibit solely the names of all companies in the query-set. My desire is for jquery to unveil the corresponding address upon clicking the name (via aja ...

Navigating redirects in HTML parsing with Python

I am currently experimenting with submitting multiple forms using a Python script and making use of the mechanized library. The purpose behind this is to set up a temporary API. The issue I am encountering is that upon form submission, a blank page appea ...

Illuminate a corresponding regular expression within a text input

I currently have a functional code for testing regex, which highlights matching patterns. However, my challenge lies in highlighting the result within the same input as the test string. Below you will see the HTML and JavaScript snippets along with two ima ...

Ways to structure a div to resemble a table

I'm currently working on a form that has multiple input fields, and I'm looking to structure them in a specific way. The layout I want to achieve can be seen in this example: https://jsfiddle.net/dmilos89/58ea82gj/2/ The example above utilizes ...

How to apply hover effect to an image within a div using TailwindCSS

Is there a way to animate only the image and not the entire card (div) when hovering over it? I want specifically for the image to perform an animation, such as bounce effect. I'm using next/image for displaying the image. Can this animation be achie ...

Photo positioned on top of the form with Bootstrap 5

I am working on creating a responsive webpage using Bootstrap, where I need to display a large image above a form. To manage the size of the image, I have placed it inside a "peek-view" container which allows scrolling both horizontally and vertically to v ...

The Challenge of CSS Transition and Checkbox Label Discrepancies

I'm looking to adjust the position of my label when a checkbox is checked. Everything works smoothly if I don't include a transition for the top offset property in the CSS of my label. However, when this transition is added (as seen in the commen ...

Achieve perfect alignment with CSS grid and maintain it as you expand your layout

I'm trying to include images along with explanations. Intended outcome: https://i.sstatic.net/B90hB.png https://i.sstatic.net/LTp2j.png https://i.sstatic.net/QvIux.png Current disappointing result: (not centered) https://i.sstatic.net/gFXZP.png h ...

Looking for a way to ensure a div reaches 100% height within a specified area without exceeding the boundaries of the body?

I am working with jQuery mobile and have specific requirements for my project: The main content will be a large graphic that needs to fill the entire page, with both horizontal and vertical scrolling if necessary. The header should remain fixed at the to ...

Using innerHTML within a JS function causes the class to malfunction

I want to embed HTML code using innerHTML, which will add an input with the class .flatpickr-date. let newInput = '<input type="text" class="flatpickr-date">' document.getElementById('id').innerHTML = newInput; In my JavaScript ...

Split Screen Text Comparisons

For some reason, I am finding it challenging to display two paragraphs side by side without disrupting the overall layout. If you would like a visual explanation of the issue, please check out this video: Video If you're interested in reviewing the c ...