Are the sizes adjustable for a desktop view?

Currently, I am in the process of establishing the fundamental elements of a responsive website. I have already defined the sizes for mobile and tablet devices, but I am uncertain about what to do for the desktop version:

For Mobile

@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {

}

For Tablet

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {

}

Are these dimensions suitable based on industry standards? How can I designate a version specifically for desktops with a width above 1024px?


/* For Mobile */
@media (min-width: 320px) { 

    .tester {
        width: 100%;
        height: 500px;
        background-color: white;
    }
}

/* For Tablet */
@media (min-width: 640px) {

    .tester {
        width: 100%;
        height: 500px;
        background-color: red;
    }   

}

/* For Desktop */
@media (min-width: 960px) {

    .tester {
        width: 100%;
        height: 500px;
        background-color: blue;
    }   

}

Answer №1

Here is the code snippet for responsive design:

@media (min-width:320px) { /* styles for smartphones and smaller devices */ }
@media (min-width:481px) { /* styles for e-readers and small tablets */ }
@media (min-width:641px) { /* styles for larger tablets and landscape devices */ }
@media (min-width:961px) { /* styles for tablets and laptops */ }
@media (min-width:1025px) { /* styles for large tablets, laptops, and desktops */ }
@media (min-width:1281px) { /* styles for high-resolution laptops and desktops */ }

Answer №2

One strategy to consider is starting with a 'mobile first' approach when designing your website. This means creating CSS that works well on mobile devices without needing media queries initially. As you develop your design, gradually include breakpoints based on the needs of the layout rather than conforming to specific device screen sizes. Although it can be helpful to test against various devices like iPhones and iPads in both portrait and landscape modes, resizing the window can also serve this purpose.

In my experience, focusing on the mobile design first tends to be more efficient than trying to retrofit a desktop design for mobile later on. By prioritizing the mobile layout, you are forced to identify the essential elements of the site early on.

Additionally, try to minimize the use of media queries to prevent confusion when revisiting the code later on. If possible, consider using a CSS preprocessor like SASS to incorporate media queries within specific classes and IDs rather than grouping them at the end of the file. This approach can make it clearer how different device sizes impact individual elements and save time scrolling through lengthy sections of code.

Answer №3

Check out this amazing list put together by Chris Coyier:

http://css-tricks.com/snippets/css/media-queries-for-standard-devices/

In general, coding for desktops doesn't have to be done separately. You can have a default code that is responsive and dynamic, with only minor adjustments needed for mobile and tablet devices.

Using a responsive framework can also make things easier, taking the worry off your shoulders.

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

Differentiate pointer for checkbox HTML

Just starting out with html and css, and I'm working with a checkbox: <input type="checkbox" name="vehicle" value="Bike">I have a bike<br> My goal is to display a hand icon when hovering over the checkbox. Ho ...

Having trouble getting CSS and Bootstrap to work in Laravel 5.8. Any suggestions on how to resolve this issue?

Facing a major issue while using Laravel 5.8 - unable to read CSS and Bootstrap. 1. Tried to run rm storage in order to execute php artisan storage:link, but it didn't work as expected. 2. After running php artisan serve failed, I switched to chdir( ...

Troubleshooting compatibility issues with Boostap4 and @media queries interfacing

Once the Bootstrap4 CDN is added, the html snippet that was perfectly stacking based on media query no longer maintains this effect. What specific aspect of Bootstrap4 is causing the stacking effect to disappear and how can it be overridden without removin ...

What is the technique for placing a div element directly within the href attribute in a shape

I am wondering if it is feasible to include the following divs <div id="cal1"> [dopbsp id="1" lang=it]</div> <div id="cal2"> [dopbsp id="1" lang=it]</div> <div id="cal3"> [dopbsp id="1" lang=it]</div> directly wit ...

The synergy between HTML and JavaScript: A beginner's guide to frontend coding

I have primarily focused on server-side development of enterprise applications (Java EE, Spring framework). However, I am now exploring client-side technologies for better understanding (not necessarily to become an expert). I have studied HTML and CSS th ...

Retrieving Text from CSS Property with Selenium in Python

Having trouble identifying an input tag html element with Selenium Python? Not because of the wait. I need to extract text from a field on a web page with a form named Form1. Here is the html element when inspected in Chrome: Input Element: <input name ...

Implementing border-right leads to alignment problems

I'm currently working on creating a list with bootstrap-Accordion using react-bootstrap. I'm applying a background color and border left to the selected item. The problem I'm facing is: Whenever I activate a bar, the text shifts to the rig ...

Is it possible for a div to contain more than one class in Twitter Bootstrap?

Is it possible for a div element to have multiple classes assigned to it? I am currently working with Twitter Bootstrap and I would like to utilize two predefined classes. Specifically, I want to apply the active class to a dropdown-toggle within a navig ...

Creating a responsive grid layout in Bootstrap that seamlessly adjusts to different screen sizes

I'm facing a challenge in creating a responsive grid using Bootstrap. The grid consists of three columns - Header, Image with height, and an action button. For mobile, each column should occupy the full width (12) whereas on larger screens they shou ...

Can a div be aligned in the center with an "absolute" parent element?

<style type="text/css"> .square { width:251px; height:207px; border: 1px solid #d6d6d6; -webkit-box-shadow: 1px 1px 3px rgba(0,0,0,.1); -moz-box-shadow: 1px 1px 3px rgba(0,0,0,.1); box-shadow: 1px 1px 3px rgba(0,0,0,.1); ...

How can I make two flexbox items in a row stack on top of each other as a column?

I'm currently working on a layout that involves a parent flexbox containing multiple sections. My challenge lies in getting two specific sections to stack vertically while the rest of the layout remains horizontal. At the moment, I have two sections ...

Turning off and on CSS transitions to set the initial position

Is there a way in javascript to position divs with rotations without using transitions initially for an animation that will be triggered later by css transition? I have tried a codepen example which unfortunately does not work on the platform but works fin ...

Having trouble centering an icon in a cell within AG Grid?

I am struggling with aligning my checkmarks within the cells of my AG Grid. Currently, they are all left aligned but I need them to be centered. Adjusting the alignment for text is not an issue, but I can't seem to center the material icons. It appear ...

Repairing the Left-sided Popup Leaflet

Can someone help me with fixing the positioning of the Popup to the left of the map? Currently, it does not stay aligned to the left edge when moving the map. I tried using position: fixed in my styling, and while everything looks good when zooming, it br ...

The inner table provides a slight padding of 1-2 pixels on its left side

Consider a scenario where there is a table: <table> <tr> <td> Hello How are you this is a TEST! </td> <tr> <tr> <td> <table> ...

Is your React application struggling to display large images when bundled with Webpack?

I am facing an issue while trying to display an image from my image folder in a React project using Webpack. I have observed that smaller photos with physically smaller dimensions and file sizes load properly, but larger photos do not render on the screen, ...

Encountering issues with the Bootstrap image gallery display

I'm a newcomer to Bootstrap and I want to create an image gallery. This is what I expect: https://i.sstatic.net/DKxMC.jpg However, what I'm getting looks like this: https://i.sstatic.net/KkrAG.jpg This is the HTML code I have so far: <div ...

Scss - Only one for mobile devices

Just dipping my toes into scss and I've got a quick question. Here's the snippet of scss code I'm working with: .page { max-width: 1200px; position: relative; width: 100%; ul{ background-color: black; width ...

Issue with the appearance of the footer in my Wordpress template

After creating a WordPress template, I noticed that the footer is not extending to 100% width as expected. Check out the page here Any suggestions on why this might be happening? Could it be due to a missing closing div tag somewhere in the code? Thank ...

ngx-bootstrap: Customizable horizontal sorting with templates

I'm encountering a problem with the ngx-bootstrap sortable component. My goal is to utilize the sortable component in a horizontal layout instead of the vertical one shown in the documentation examples. ngx-bootstrap sortable If anyone has a solutio ...