Responsive CSS isn't working properly? - css
Here's the site: Website
There are some navigation arrows I'm trying to hide in mobile view.
Here's the HTML...
<div id="nav_arrow">
<img src="images/icons/arrow_left.png" width="60" height="44">
</div>
Here's the CSS...
#nav_arrow { display: none; }
The media query appears to be typed out correctly. The style works when the phone (iPhone 5) is held vertically. But, when I hold it in a landscape view, the arrows show up. I'm trying to not have them display unless the site is pulled up in tablet view or larger?
Any ideas?
Update 1
This is the section of CSS where I have the media query...
#media only screen and (max-width: 480px) {
#nav { display:none;}
#secondary-nav { display:none; }
#footer-social { float:left; }
.jcarousel-skin-tango .jcarousel-next-horizontal { right:0; }
.jcarousel-skin-tango .jcarousel-prev-horizontal { right: 43px;}
.jcarousel-skin-tango .jcarousel-item { width: 300px !important; }
.jcarousel-skin-tango .jcarousel-item-horizontal {margin-right: 20px;}
#latest-projects .block, #latest-posts .block, .programs .block { width:295px; height:inherit; }
#latest-projects .stack, #latest-posts .stack, .programs .stack { width:295px; height:274px; }
#latest-projects .block img, #latest-posts .block img, .programs .block img { width:283px; height:262px; }
#latest-projects .block .mask, #latest-posts .block .mask, .programs .block .mask { width:283px; height:261px; }
.nav-projects .viewall { display:none;}
#clients .block { width:298px;}
#clients .block img { width:298px;}
#info-block ul li > div { height: 85px; width: 270px; }
#latest-projects .block iframe, #latest-posts .block iframe, .programs .block iframe { width:283px; height:262px; }
.fix-fish-menu select { display:block; }
#menu { float: none; }
#clients .columns { padding-bottom:20px; }
.ribbon-front { left: 1px; }
.ribbon-edge-topleft, .ribbon-edge-bottomleft { display:none; }
#footer-social li { margin-right: 5px; margin-left: 0px; }
#top-panel .columns { margin-bottom:20px;}
#contacts-form input[type=text], #contacts-form input[type=password], #contacts-form input[type=email] { width:130px;}
#contacts-form textarea { width: 290px; }
#contact-info li { width:275px; }
#latest-posts .mejs-container {width:265px !important;}
#latest-posts .block .text { height: 200px;}
#latest-posts .block { width:295px; height:274px; }
#nav_arrow { display: none; }
.link-icon { background-position: top: 100px; right: 100px; bottom: 100px; left: 60px; }
The specific tag is on the bottom. Second to last.
Screen in media queries are defined as anything on an screen, so not print, or other similar medias. Your media query is saying that those styles will only be displayed on a screen, and the screen has to be less than 480 pixels.
Chances are that when you tilt your iPhone to landscape, it increases the pixels past 480. So then all of those styles in that block are not applied, and the iPhone renders the default styles of screens bigger than 480 pixels. There are a few ways to solve this.
You could increase the max-width pixel value. This might be the solution you will have to go to. You will just have to be careful picking a value
You don't want it too low. If you only target iPhone for this value, then any phones with a bigger screen won't have those styles. So you'd be back to the same problem
You don't want it too high, because you might end up accidentally targeting some smaller screen notebooks, and then you have destroyed a little part of your UI
Chris posted a good article relating to this. He has a lot of media queries you could use to solve this. But that might get a little heavy with queries.
Unfortunately, there isn't a query made yet that only targets handheld devices
Are you sure you are using the right mediaquery?, have you tried the orientation property:
#media only screen and (min-device-width : 320px) and (max-device-width : 568px) and (orientation : landscape) {}
or maybe device-aspect-ratio would be more accurate for iphone 5:
#media screen and (device-aspect-ratio: 40/71) and (orientation : landscape) {}
The width of the iphone5 landscape is 568px, so change your media query to something like:
#media only screen and (max-width: 568px).
Maybe use 768 as a breakpoint for tablets (portrait).
Related
specific media query not overriding?
So I have an element that I want to change at 750px and 500px: .footer-logo img { content:url(...); } and then: #media only screen and (max-width: 700px) { .footer-logo img{ margin-top: -58px !important; padding:64px; } } #media only screen and (max-width: 500px) { .footer-logo img { width: 80vw !important; max-width:none !important; margin-top:-10px !important; } The 500px changes happen but the changes when testing at 700px do not happen. I know I shouldn't be using !important so much but the styling just won't happen without it... Any help is appreciated
You can Try This. please check div Color changes According to media query HTML <div class="footer-logo"> <img src="http://dummyimage.com/100x50/000/fff&text=Throbble!"> </div> CSS #media only screen and (max-width: 700px) { .footer-logo > img{ margin-top: -58px !important; padding:64px; } .footer-logo { background-color:yellow; } } #media only screen and (max-width: 500px) { .footer-logo > img { width: 80px !important; max-width:none !important; margin-top:-10px !important; } .footer-logo { background-color:red; } }
CSS small screen issue
My query was about my wordpress site womensfertility n hormones. c o m if I view the site on a smaller screen with resolution like 1024 x 768 the site would look like this: but if I view it on my normal computer screen with big resolution it looks good, then if I scale it to iphone and ipad it would scale normal as it is responsive. I'm using optimizepress. I've just added a code to make the site boxed layout and to have a background image instead of full width. my code that I've added was: .banner .logo img{width:200px} .banner.centered-banner > .fixed-width .banner-logo { width: 100%; } .container { margin: auto; overflow: hidden; padding: 0; position: relative; width: 75%; } I guess the width: 75%; and the .banner .logo img { width: 200px; } makes the site looks that way, but I have no idea how to make the site look like boxed without doing that code. Any idea?
use CSS Media Queries #media (max-width: 600px) { /*code for screen with max with 600px*/ } #media (max-width: 480px) { /*code for screen with max with 480px*/ } or: body { color: white; background: gray; font-size: .5in } #media screen and (min-width: 1024px){ body { background: red; } } #media screen and (min-width: 641px) and (max-width: 1023px){ body { background: yellow; } } #media screen and (max-width: 640px){ body { background: green; } } for example : #media (max-width: 480px) { .banner .logo img{width:140px} .banner.centered-banner > .fixed-width .banner-logo { width: 80%; } .container { width: 35%; } }
I can't get my mobile version of site exactly centered
I'm having some odd space issues on the left of my site. For some reason there is slightly more space on the left than on the right in mobile view, thus looking off-centered. I'm guessing its off for desktop view as well, but its not noticeable. I can't figure out what is making it this way. http://jeffreydowellphotography.com/ /* ---------->>> MOBILE gap/space issues <<<-----------*/ #media screen and (max-width: 400px) { #pageWrapper { margin: 0;} .sqs-layout .sqs-row .sqs-block:last-child { padding-bottom: 0; padding-top: 0; }} /* ---------->>> MOBILE center logo <<<-----------*/ #media only screen and (max-width: 400px) { h1.logo { text-align:center; margin-bottom: 20px !important; }} /* ---------->>> MOBILE logo size <<<-----------*/ #media only screen and (max-width: 400px) { .logo-image .logo img { max-height: 110px; margin: 5px; width: auto; } .social-links { padding-top: 20px; }}
Try removing the margin: 5px; on .logo-image .logo img in your mobile styles. The image with the margin may be wider than the div that contains the image and it comes off as being non-centered. UPDATE I took a look at your site, its actually the margin on the .slide selector. Add this in your mobile styles: .slide { margin: 0; }
hide div tag on mobile view only?
I'm creating a fluid layout for a site. I'm trying to hide the contents of a <div> or the whole <div> itself in the mobile view, but not the tablet and desktop view. Here's what I've got so far... #title_message { clear: both; float: left; margin: 10px auto 5px 20px; width: 28%; display: none; } I have the display set to 'none' for the mobile layout and set as block on the tablet/desktop layouts... Is there an easier way to do that, or is that it?
You will need two things. The first is #media screen to activate the specific code at a certain screen size, used for responsive design. The second is the use of the visibility: hidden attribute. Once the browser/screen reaches 600pixels then #title_message will become hidden. #media screen and (max-width: 600px) { #title_message { visibility: hidden; clear: both; float: left; margin: 10px auto 5px 20px; width: 28%; display: none; } } if you are using another CSS for mobile then just add the visibility: hidden; to #title_message.
Set the display property to none as the default, then use a media query to apply the desired styles to the div when the browser reaches a certain width. Replace 768px in the media query with whatever the minimum px value is where your div should be visible. #title_message { display: none; } #media screen and (min-width: 768px) { #title_message { clear: both; display: block; float: left; margin: 10px auto 5px 20px; width: 28%; } }
The solution given didn't work for me on the desktop, it just showed both divs, although the mobile only showed the mobile div. So I did a little search and found the min-width option. I updated my code to the following and it works fine now :) CSS: #media all and (min-width: 480px) { .deskContent {display:block;} .phoneContent {display:none;} } #media all and (max-width: 479px) { .deskContent {display:none;} .phoneContent {display:block;} } HTML: <div class="deskContent">Content for desktop</div> <div class="phoneContent">Content for mobile</div>
#media only screen and (min-device-width : 320px) and (max-device-width : 480px) { #title_message { display: none; }} This would be for a responsive design with a single page for an iphone screen specifically. Are you actually routing to a different mobile page?
You can be guided by this example. On your css file: .deskContent { background-image: url(../img/big-pic.png); width: 100%; height: 400px; background-repeat: no-repeat; background-size: contain; } .phoneContent { background-image: url(../img/small-pic.png); width: 100%; height: 100px; background-repeat: no-repeat; background-size: contain; } #media all and (max-width: 959px) { .deskContent {display:block;} .phoneContent {display:none;} } #media all and (max-width: 479px) { .deskContent {display:none;} .phoneContent {display:block;} } On your html file: <div class="deskContent">Content for desktop</div> <div class="phoneContent">Content for mobile</div>
i just switched positions and worked for me (showing only mobile ) <style> .MobileContent { display: none; text-align:center; } #media screen and (max-width: 768px) { .MobileContent { display:block; } } </style> <div class="MobileContent"> Something </div>
Well, I think that there are simple solutions than mentioned here on this page! first of all, let's make an example: You have 1 DIV and want to hide thas DIV on Desktop and show on Mobile (or vice versa). So, let's presume that the DIV position placed in the Head section and named as header_div. The global code in your CSS file will be: (for the same DIV): .header_div { display: none; } #media all and (max-width: 768px){ .header_div { display: block; } } So simple and no need to make 2 div's one for desktop and the other for mobile. Hope this helps. Thank you.
try this #media handheld{ #title_message { display: none; } }
responsive media queries in stylesheet not working
My CSS isn't working on mobile portrait. I want the main top menu to appear beneath the logo. Here is my css at the mo: #media screen and (max-width: 480px) { #wrapper { width:100%; } #logo { margin-left: 100px; } #menu { width:100%; display:inline-block; } }
Hi now define your wraper width 100% into 480px as like this #media screen and (max-width: 480px) { #wrapper { width:480px; } #logo { margin-left: 100px; } #menu { width:100%;display:inline-block; } }