I am currently in an intro HTML/CSS class and I am having trouble optimizing my webpage for various mobile resolutions. I have been using a website resolution simulator to test and my layout always looks wonky on certain settings.
Is there way to auto detect resolutions using HTML and CSS?
Edit: I have added a meta viewport already
Yes there is.
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
Source:http://css-tricks.com/snippets/css/media-queries-for-standard-devices/
Related
Initially I had my base CSS and then I added a 640 media query...
#media screen and (max-width:640px) {}
I coded everything to fit mobile devices and everything was fine. A little bit ago I added another media query...
#media screen and (max-width:840px) {}
Now, the mobile part of my site is taking the second media query's code? I don't know a phone that has a max width that large. Why is the 840 media query disturbing my mobile media query?
In order to prevent the override of CSS, use the below code to specify rules only for width between 640px and 840px:
#media screen and (min-width: 640px) and (max-width:840px) {
/* CSS rules for width between 640px and 840px */
}
Alternatively you can reorder the code:
#media screen and (max-width:840px) {}
#media screen and (max-width:640px) {} /* This will override the above CSS rules */
Check out this page: MDN Media Queries to learn some good practices.
The Position (order) of the media queries in the .css file plays an important role, they are in ascending priority order (top to bottom ) in the .css file, you just need to change this order as follows:
Put this #media screen and (max-width:840px) {} media query, above this one #media screen and (max-width:640px) {} and it will fix the issue.
Alternatively you can use the following CSS:
#media screen and (min-width: 640px) and (max-width:840px) {
/* your code here */
}
You can use what manoj said.
This is a guide from CSS tricks - Hope this helps
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
To which part does my layout answer and how can I change it? I have tried changing the screen size in the Dw Design page but I don't think it's responding.
you need Dreavweaver CC to design for mobile, although its not necessary
just use this guide in your css file and add the css for each device
/* Smartphones (portrait and landscape) ----------- */
#media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen and (min-width : 1224px) {
/* Styles */
}
Is it feasible to developers specify when the contents of the web page stack by responsive design? So for example if you are in 1200 x 1800 resolution, you are in the following display:
[A] [B]
However, if you are in 1000 x 1800 resolution, your display automatically in the following stack format by the virtue of Twitter Bootstrap's responsive functionality (I use Bootstrap 3):
[A]
[B]
However, is it feasible for developers specify when the responsiveness occurs - for example, when the resolution is less than 1100 x 1800, the above stack occurs - and if it's feasible, how can I specify it?
I use Bootstrap, HTML5, CSS3 as well as node.js, but I think node is irrelevant in this case.
I use Google Chrome, and don't care about how the other browsers react to the change.
Thanks.
One approach may be to have a look at media queries (2), e.g. quoting from Mozilla
<!-- CSS media query on a link element -->
<link rel="stylesheet" media="(max-width: 800px)" href="example.css" />
<!-- CSS media query within a style sheet -->
<style>
#media (max-width: 600px) {
.facet_sidebar {
display: none;
}
}
</style>
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
I hope help you
Here is this website:
http://www.morpheuscommerce.com/
Now this is what happens when i view the site on an ipad:
http://i.imgur.com/I4cQ9Yb.jpg
A similar thing happens on iphone. On desktop it looks fine at first but when you resize the browser and move the scrollbar to the right, the background is broken is well!
Ive tried so many things to try fix this but Im not sure whats causing the problem in the first place.
Your website it's no responsive layout.
You can change this with css #media
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
Search more about responsive layout.
I am working on a webpage using HTML and CSS. When I have my browser in full screen, everything looks good. However, if I resize my browser, the text shows up on top of the image. I have tried to google about this, but did not get any resolution. Has anyone experienced similar situation, and knows of a solution? Please share your thoughts.
The code is in the link:
http://jsfiddle.net/eJyZs/
Btw, I am using SimpleGrid as well. http://simplegrid.info/
I think you have made mistake in CSS.
It's image Position problem. so, change your style sheet.
for example: position:fixed; top:30px; right:5px;
so, change position fixed to anything you want... for more help look at here.. http://www.w3schools.com/Css/css_positioning.asp
Hi now used to Media Queries for Standard Devices
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
#media only screen
and (min-width : 321px) {
/* Styles */
}
/* Smartphones (portrait) ----------- */
#media only screen
and (max-width : 320px) {
/* Styles */
}
/* iPads (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) {
/* Styles */
}
/* iPads (landscape) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) {
/* Styles */
}
/* iPads (portrait) ----------- */
#media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) {
/* Styles */
}
/* Desktops and laptops ----------- */
#media only screen
and (min-width : 1224px) {
/* Styles */
}
/* Large screens ----------- */
#media only screen
and (min-width : 1824px) {
/* Styles */
}
/* iPhone 4 ----------- */
#media
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}
more info