I recently started learning responsive design for mobiles etc and i am using troy.labs.daum.net to test on, it started out working fine on my first two media queries although when I choose from the resolution list now it only shows the 400px width query
heres my css
#media only screen and max-width 320px {
#searcher
{
width:190px;
height:30px;
float:left;
}
#searcherin
{
width:185px;
height:16px;
margin-top:6px;
border:1px solid #ccc;
padding-left:4px;
text-transform:capitalize;
}
}
#media only screen and max-width 360px {
#searcher
{
width:230px;
height:30px;
float:left;
}
#searcherin
{
width:225px;
height:16px;
margin-top:6px;
border:1px solid #ccc;
padding-left:4px;
text-transform:capitalize;
}
}
#media only screen and max-width 400px {
#searcher
{
width:268px;
height:30px;
float:left;
}
#searcherin
{
width:264px;
height:16px;
margin-top:6px;
border:1px solid #ccc;
padding-left:4px;
text-transform:capitalize;
}
}
Am I doing something wrong with this?
The links is http://2click4.com/new/mobile/home.php
Reverse the order start with the biggest and have the smallest at the end. For smaller size, you only need to define the rules that changed between the current size and the previous as the 360 will carry the rules from 400 and above.
#media only screen and (max-width: 400px) { ... }
#media only screen and (max-width: 360px) { ... }
#media only screen and (max-width: 320px) { ... }
http://jsfiddle.net/88wgM/
Resize the viewing area and see the change, if you reverse it like in your code, it does not work
Make sure you have
(max-width: 400px)
the () and : after max-width
When you starting develop responsive design its very important you specify the orientation!
/*Tablet devices*/
#media only screen and (min-width: 0px) and (max-width: 320px) and (orientation: landscape) {
...
}
/*Tablet devices*/
#media only screen and (min-width: 321px) and (max-width: 360px) and (orientation: landscape) {
...
}
/*Tablet devices*/
#media only screen and (min-width: 361px) and (max-width: 400px) and (orientation: landscape) {
...
}
First off all you need to specify the lowest width devices. Then you move to biggest ones!
Here is a good boilerplate you can use to start your media queries in your stylesheet.
// Small screens
#media only screen { } /* Define mobile styles */
#media only screen and (max-width: 40em) { } /* max-width 640px, mobile-only styles, use when QAing mobile issues */
// Medium screens
#media only screen and (min-width: 40.063em) { } /* min-width 641px, medium screens */
#media only screen and (min-width: 40.063em) and (max-width: 64em) { } /* min-width 641px and max-width 1024px, use when QAing tablet-only issues */
// Large screens
#media only screen and (min-width: 64.063em) { } /* min-width 1025px, large screens */
#media only screen and (min-width: 64.063em) and (max-width: 90em) { } /* min-width 1025px and max-width 1440px, use when QAing large screen-only issues */
// XLarge screens
#media only screen and (min-width: 90.063em) { } /* min-width 1441px, xlarge screens */
#media only screen and (min-width: 90.063em) and (max-width: 120em) { } /* min-width 1441px and max-width 1920px, use when QAing xlarge screen-only issues */
// XXLarge screens
#media only screen and (min-width: 120.063em) { } /* min-width 1921px, xlarge screens */
Related
I have a twitter bootstrap 3 application and the SVG logo looks great in Desktops but looks truncated in the mobile browsers e.g. iOS Safari.
My very standard code looks like this:
<!-- RD Navbar Brand-->
<div class="rd-navbar-brand brand">
<a class="brand-name" href="/"><img src="images/logo.svg" height="100"></img></a>
</div>
Is there a way, for example, to reduce the logo size in case of mobile device detected?
you can use media queries like this:
/* Large desktops and laptops */
#media (min-width: 1200px) {
.my-logo {
width:300px;
}
}
/* Landscape tablets and medium desktops */
#media (min-width: 992px) and (max-width: 1199px) {
.my-logo {
width:250px;
}
}
/* Portrait tablets and small desktops */
#media (min-width: 768px) and (max-width: 991px) {
.my-logo {
width:200px;
}
}
/* Landscape phones and portrait tablets */
#media (max-width: 767px) {
.my-logo {
width:150px;
}
}
/* Portrait phones and smaller */
#media (max-width: 480px) {
.my-logo {
width:100px;
}
}
I have this issue where my media queries are messing up on my iPhone and iPad, my tablet media query is targeted on my iPhone so the layout on mobile is all wrong.
I have already checked my ordering of the media queries, and they are from smallest to biggest since as I styled the page starting from mobile view first.
.career-feature-icon {
width: 100%;
height: 300px;
padding: 10px;
#media screen and (min-width: 37.5rem) {
float: left;
width: 50%;
}
#media (min-width: 64rem) {
width: 25%;
}
img {
width: 200px;
height: 200px;
display: block;
margin: 0 auto;
}
h2 {
text-align: center;
#media (min-width: 64rem) {
padding-top: 20px;
}
}
}
My styling is there, but it is overruled by whatever is in the 37.5rem media query.
Again this is ONLY on iOS devices, any help is greatly appreciated!
SOLVED: I changed my media query from REM to px 37.5rem -> 600px 64rem -> 1024px and it rendered the way it should
/*
##Device = Tablets, Ipads (portrait)
##Screen = B/w 768px to 1024px (48rem to 64rem)
*/
#media (min-width: 768px) and (max-width: 1024px) {
//CSS
}
/*
##Device = Tablets, Ipads (landscape)
##Screen = B/w 768px to 1024px
*/
#media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
//CSS
}
/*
##Device = Low Resolution Tablets, Mobiles (Landscape)
##Screen = B/w 481px to 767px (30.065rem to 47.93rem)
*/
#media (min-width: 481px) and (max-width: 767px) {
//CSS
}
/*
##Device = Most of the Smartphones Mobiles (Portrait)
##Screen = B/w 320px to 480px (20rem to 30rem)
*/
#media (min-width: 320px) and (max-width: 480px) {
//CSS
}
Try this might work
Media queries for CSS class
am using .CSSTableGenerator as a css class for table. how to use Media queries for this CSS class file only?
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
body {
padding: 0;
margin: 0;
width: 320px; }
}
/* iPads (portrait and landscape) ----------- */
#media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
body {
//width: 495px;
}
}
#media only screen and (max-width:992px){
}
#media only screen and (max-width: 400px){
}
Use Like this keep Grater size first than lower
None of the solutions given previously in stackoverflow solved my problem. If anyone has solution to this, then please please please help me. I want: the horizontal scroll bar should appear when the browser is minimized and divs should not overlap each other
html code for header:
<header><label class="font_white">LIZA's World</label>
<nav>
<ul>
<li>hellohello |</li>
<li>HIHO |</li>
<li>Heyhey |</li>
<li>Ciao Ciao Ciao Ciao |</li>
<li><label class="nav_name">Liza</label></li>
<li>
<form id="search" method="get" action="hello.html" style="float:right">
<input type="text" class="searchbar" size="50" maxlength="120" value="Search..." />
<input type="button" class="search_button"/>
</form>
</li>
</ul>
</nav>
</header>
css code for header and nav:
html, body {
overflow-x:scroll;
}
header {
position: fixed;
height: 40px;
top: 0px;
width: 100%;
vertical-align: top;
background:#2748ab;
margin-left:-8px;
}
nav
{
position: fixed;
vertical-align: top;
margin-top:10px;
top: 0px;
float:left;
margin-left:23%;
width:76.5%;
}
I changed the nav as follows:
nav
{
position: fixed;
vertical-align: top;
margin-top:10px;
top: 0px;
float:left;
margin-left:320px;
min-width:1000px;
}
now the overlapping problem is solved but, the horizontal scrollbar problem is not solved yet.
If you measure the total outer width of the layout. and set the min-width of outer div or body. if resize the browser it shown horizontal scroll bar and alignment not varied.
Ex:
.outerdiv{min-width:1240px;}
or
body{min-width:1240px;}
You need to add media in CSS, understand how to add media into css and make your website responsive.
/*------------------------------------------
Responsive Grid Media Queries - 1280, 1024, 768, 480
1280-1024 - desktop (default grid)
1024-768 - tablet landscape
768-480 - tablet
480-less - phone landscape & smaller
--------------------------------------------*/
#media all and (min-width: 1024px) and (max-width: 1280px) {
.logo{
width:80px;
}
}
#media all and (min-width: 768px) and (max-width: 1024px) {
.logo{
width:80px;
} }
#media all and (min-width: 480px) and (max-width: 768px) {
.logo{
width:50px;
} }
#media all and (max-width: 480px) {
.logo{
width:100%;
}
}
/* Portrait */
#media screen and (orientation:portrait) {
.logo{
width:100%;
}
}
/* Landscape */
#media screen and (orientation:landscape) { /* Landscape styles here */ }
/* CSS for iPhone, iPad, and Retina Displays */
/* Non-Retina */
#media screen and (-webkit-max-device-pixel-ratio: 1) {
}
/* Retina */
#media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
}
/* iPhone Portrait */
#media screen and (max-device-width: 480px) and (orientation:portrait) {
}
/* iPhone Landscape */
#media screen and (max-device-width: 480px) and (orientation:landscape) {
}
/* iPad Portrait */
#media screen and (min-device-width: 481px) and (orientation:portrait) {
}
/* iPad Landscape */
#media screen and (min-device-width: 481px) and (orientation:landscape) {
}
You just need to check which resolution you want to make responsive and particular CSS into that media. You need to use more inspect element for testing. You also add responsive menu code. So your header will adjust perfectly.
I will suggest you to use https://webflow.com for developing responsive website. So you dont need to worry about responsive headache.
I'm building a responsive site but when I resize the window the media queries aren't corresponding with my screen resolution, so for instance,
#media screen and (min-width:640px) and (max-width: 800px) is resulting in these design elements to be when the screen is above 800 pixels and when I'm at 700 pixels my designs are being set to #media screen and (min-width: 400px) and (max-width:640px) for some reason. Does anyone know why this could be happening?
Update: The max-width 640px media query is being set to my screen at over 700 pixels still.
#media screen and (max-width: 1024px) {
.body{
width:800px;
}
}
#media screen and (max-width: 800px) {
.body {
width:600px;
}
}
#media screen and (max-width:640px) {
.body {
width:480px;
}
}
#media screen and (max-width:400px) {
.body {
width:260px;
}
}
To start troubleshooting, double check that in the head of your document you have
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Let me know how you get on.
Edit
Thanks for the extra code. Check out this working example. The CSS and the order of the media queries is below:
/* set default */
.body{
width:800px;
}
#media screen and (max-width:400px) {
.body {
width:260px;
}
}
#media screen and (min-width: 401px) and (max-width:640px) {
.body {
width:480px;
}
}
#media screen and (min-width: 641px) and (max-width: 800px) {
.body {
width:600px;
}
}
#media screen and (min-width: 801px) and (max-width: 1024px) {
.body{
width:800px;
}
}