Is Your Website Optimized for All Devices?

Creating this website was just a little project for me. I've been experimenting with different methods to ensure it's compatible with all devices and fits perfectly on each screen.

Unfortunately, I'm pretty clueless when it comes to @media queries and JavaScript. So, I'm not sure what options are available to me.

Here is the code I am currently using, although I still need to scroll right to see the entire page:

<meta name="viewport" content="width=device-width, initial-scale=0">
<link rel="stylesheet" href="/script/jquery.mobile-1.4.3.css">
<script type="text/javascript" src="/script/jquery.mobile-1.4.3.js"></script>

I'm no HTML expert, just tinkering around and trying to create things.

One solution I'm aware of is reducing the size of my images. However, this may not achieve the appearance I desire.

Also, how can I center my 'Back To Top' button on every page and device?

Javascript:


        <script type="text/javascript>
        jQuery(document).ready(function() {
            var offset = 220;
            var duration = 500;
            jQuery(window).scroll(function() {
                if (jQuery(this).scrollTop() > offset) {
                    jQuery('.back-to-top').fadeIn(duration);
                } else {
                    jQuery('.back-to-top').fadeOut(duration);
                }
            });

            jQuery('.back-to-top').click(function(event) {
                event.preventDefault();
                jQuery('html, body').animate({scrollTop: 0}, duration);
                return false;
            })
        });
    </script>

Body Code:

<p style="text-align:center"><a href="#" class="back-to-top">Back to Top</a>

CSS:

.back-to-top {
 position: fixed;
 bottom: 0px;
 right: 44%;
 text-decoration: none;
 color: transparent;
 background-color: rgba(0, 230, 0, 0.10);
 font-size: 13px;
 padding: 1em;
 display: none;
 border: 1px solid #CCFF33;
 border-radius: 4px;
 box-shadow: 0 0 8px 1px #00E600;
 color: #C1C1C1;
 outline: none;
 height: 10px;
 width: 180px;
 font-weight: 700;
 letter-spacing: 2px;
 text-shadow: 0 0 0.2em #000, 0 0 0.2em #000, 0 0 0.2em #000;
 text-align: center;
}

.back-to-top:hover {
 background-color: rgba(255, 0, 0, 0.10);
}

Answer №1

Understanding Media Queries for Responsive Design

In this example, the concept of media queries is explored starting with a mobile-first approach. Different attributes are adjusted for each screen size to ensure optimal user experience.

/* Mobile Layout: Styles for screens 480px and below */

exampleDiv {
 Width:60%;
 height:100px;
}

/* Tablet Layout: Styles for screens 481px to 768px. Inherits from Mobile Layout */

@media only screen and (min-width: 481px) {
exampleDiv {
 Width:60% height:300px;
}
}

/* Desktop Layout: Styles for screens 769px to maximum of 1232px. Inherits from Mobile Layout and Tablet Layout */

@media only screen and (min-width: 769px) {
exampleDiv {
 Width:100% height:500px;
}
}

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

Manipulating the visibility and opacity of a div element using CSS

Here is the code snippet I am working with: <div class="contact-item" onmouseover="div_ContactItem_mouseover(this)"> </div> <div id="div_ItemOver" style="display: none;" class="contact-item-hover" onmouseout="div_ItemOver_mouseout ...

Utilizing CSS classes to style custom day templates in ng-bootstraps datepicker

Currently, I am utilizing ng-bootstraps datepicker to showcase user data on a daily basis. I have implemented a custom day template to apply specific CSS classes. <ng-template #customDay let-date> <div class="custom-day" [ngCla ...

Utilize dojo to manually trigger a window resize event

Is there a way to manually trigger the window resize event (the one that occurs when you resize your browser window) using Dojo? I need this functionality to dynamically resize my C3 Charts. I came across the on module in Dojo, which allows for listening ...

Implement a ClickEvent on a button through JavaScript, JQuery, or Bootstrap

A fun game idea I'm working on involves smurfs and toadstools. I've already made some progress, but unfortunately can't share direct images due to my reputation level. But each of the white/red and white/blue circles in the game represent ...

Once the final row in the table is removed, the width of the second cell in the top row will be set to 0

Can anyone help with an issue I'm having on my website? I created a basic web page with some Javascript that allows for inserting and deleting table rows. However, I've noticed that in IE6, when I delete the last inserted row, the second cell of ...

What is the best way to ensure an image fits perfectly within a div container

I'm attempting to design a straightforward card layout where the image spans the entire width of the container div. My vision is for it to resemble something like the example in the linked image below. https://i.sstatic.net/X5oJD.png I experiment ...

The jQuery script seems to be failing to execute

Recently, I have been delving into the world of jQuery. However, after adding my code, the functions I set up are failing to run. Strangely enough, just two weeks ago everything was running smoothly without any errors in linking files within my HTML docume ...

Next.js 11 Script integration for TruConversion Heatmap Tracking

I'm in the process of setting up TruConversion's heatmap script on my Next.js 11 website. According to TruConversion's website, the script should be added before the closing </head> tag. However, Next.js documentation advises against ...

What could be causing the error to occur in the form when I try to submit it?

After creating a page in bootstrap 4, I encountered an issue with the modal. Whenever I click on any input field or button inside the modal, it shows the same error message. I'm quite confused and don't know what's causing this problem. Upon ...

Show a popover within a parent div that has limited visible space due to its hidden overflow

Struggling with AngularJS, I can't seem to find a simple solution for this problem. In my code, there's a div element with the overflow: hidden property set due to an internal scrollbar. Inside this div, there's a dropdown menu that is trigg ...

What is the accurate option to choose - jsonlint or JSON.parse?

I was trying to work with a JavaScript string where a key has a value that is the string representation of an array: { "a": "[\"b\",\"c\"]" } Interestingly, jsonlint.com states that this is a valid format. JSON.parse('{"a":"[& ...

Troubleshooting: Issue with passing parameters in Wordpress ajax function

In my Wordpress Ajax implementation, I am facing an issue where the parameter value metakey: id is not being passed to $_POST["metakey"]. As a result, when I do a var_dump($_POST), it shows array(0) { }. If I manually set a static value for the variable i ...

Implementing dynamic styles for a checked mat-button-toggle in Angular 6

How can I customize my button-toggle when it is checked? The current code I have doesn't seem to be working... This is the code snippet: <mat-button-toggle-group #mytoggle (change)="selectoption($event)" value="{{num}}"> <mat-bu ...

The transparency of the image remains slightly see-through even after adjusting the opacity value

Functionality: The current page design includes a translucent background with an opacity of 0.68, and an image placed on top with a full opacity of 1.0. However, the issue arises when the image inherits the transparency property from the background. The g ...

Place a locator on the variable at the identical level

My objective is to locate an element with both an id and a class. I achieve this using the following code snippet: return element(by.css('#right.closed')).isPresent(); While this method works correctly, I am looking to enhance it by introducing ...

Having trouble grasping the inner workings of code while iterating through a JSON array in ReactJS

Currently, I am immersed in a school project that requires me to develop a simple CRUD web application. After weighing my options, I decided to utilize Spring Boot + ReactJS for this endeavor. The progress has been smooth so far, but I must admit that part ...

I am looking to retrieve a sophisticated/nested JSON data using jQuery

I need some assistance in fetching specific JSON object data. Specifically, I am looking to extract the name, poster image URL, size of the second backdrop image, and version number. As a newcomer to JSON, I was wondering if there is an easy way for me to ...

Maintaining the order of elements in Angular's insertion process

I am currently facing an issue with my HTML fragment that iterates over a key and value collection. Everything works perfectly when I insert values into an object and iterate through it using the HTML fragment. However, in order to maintain a specific key ...

Navigating through the Table using AngularJS

I was able to successfully loop through a table using AngularJS to retrieve values from a specified scope named {{rec}} as shown below. HTML <div id="AngularContainer" data-ng-app="myApp" data-ng-controller="myCtrl"> < ...

Is it Possible to Modify CSS Dynamically within an Angular Directive?

I am currently developing a directive for an input field of type text. My goal is to have the width of this field expand dynamically if the text exceeds the size of the input field. Below is the code snippet for my directive: .directive('dynamicInput ...