Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

issue with CSS media queries(scrollbar)

Tags:

I am having problem with css media query in Firefox. It works correct in Chrome like I made two DIVs and want a scrollbar. If I decrease the screen size of firefox upto 800px then both DIVs collapse and after some pixels media query works but that not happens in Chrome.

check this fiddle http://jsfiddle.net/RMvqC/2/

like image 994
anil tiwari Avatar asked Nov 16 '11 04:11

anil tiwari


People also ask

How do I fix the scroll bar in CSS?

The easy fix is to use width: 100% instead. Percentages don't include the width of the scrollbar, so will automatically fit. If you can't do that, or you're setting the width on another element, add overflow-x: hidden or overflow: hidden to the surrounding element to prevent the scrollbar.

Do media queries include scrollbar?

Scrollbar not included in media query width As noted in the older article I linked to, desktop versions of Chrome, Safari, and other WebKit-based browsers do not include the vertical scrollbar in media query widths.

Why media queries is not working?

Media Query Not Working on Mobile Devices If media queries work on desktop and not on mobile devices, then you most likely haven't set the viewport and default zoom. Note: You only need to add one of the code lines above, and usually, the first one does the job.

How do I fix the horizontal scrollbar in CSS?

To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML.


2 Answers

I SOLVED this issue by calling the "mqGenie" javascript in the head of my project.

Now the widths of my media queries work fine ( with the same value ) on Chrome, Safari, Firefox and IE with or without scroolbars.

This javascript Adjusts CSS media queries in browsers that include the scrollbar width in the viewport width so they fire at the intended size.

You can download it from this url:

http://stowball.github.io/mqGenie/

like image 198
user3245967 Avatar answered Oct 18 '22 10:10

user3245967


Firefox & Webkit based browsers render the scrollbar differently. In Firefox, MediaQuery considered width of scrollbar which is 15px with the screen width, but in Webkit based browsers it's not considered scrollbar with the screen width. So, that's why the floated DIVs are collapsed in Firefox.

I did some stuff with css may be that's help you. (check this fiddle)

        html {             /* force scrollbars */             height: 101%;         }         body {             margin: 0;              padding:0;              white-space:nowrap;          }           #box1,         #box2 {             display:inline-block;             width: 400px;             height: 200px;               vertical-align:top;             white-space:normal;         }         #box1 {             background: #ce0000;              margin-right:-5px;         }         #box2 {             background: #8e0000;         }          @media screen and (max-width: 799px) {              body {                  white-space:normal;              }             #box1,             #box2 {                 width: 300px;             }         } 
like image 36
sandeep Avatar answered Oct 18 '22 11:10

sandeep