#media is giving me some problems... I can' seem to figure out how to get it to work. I would like to show the scrollbars if the height/width matches the query.
Here is what I have tried :
.content {
width: 600px;
height: 600px;
background: red;
}
#media all and (max-width: 500px) {
body{
overflow-x: visible;
}
}
#media all and (max-height: 500px) {
body{
overflow-y: visible;
}
}
body {
overflow: hidden;
}
and the fiddle: http://jsfiddle.net/Ln4tg3ct/
Either put your #media rules last in the order or make them more specific. E.g. either this:
body {
overflow: hidden;
}
#media all and (max-width: 500px) {
body{
overflow-x: visible;
}
}
#media all and (max-height: 500px) {
body{
overflow-y: visible;
}
}
or this
#media all and (max-width: 500px) {
html body{
overflow-x: visible;
}
}
#media all and (max-height: 500px) {
html body{
overflow-y: visible;
}
}
body {
overflow: hidden;
}
Make sure that your body style is listed before the media queries. Instead of using visible use scroll. In your JSFiddle, try this:
.content {
width: 600px;
height: 600px;
background: red;
}
body {
overflow: hidden;
}
#media all and (max-width: 500px) {
body{
overflow-x: scroll;
}
}
#media all and (max-height: 500px) {
body{
overflow-y: scroll;
}
}
by default, the scrollbar is visible in all. did you hide it in global CSS or something?
even on mobile, it's still visible but it's small and shows when you scroll then hides automatically.
anyway, I did the opposite to hide scrollbar #media. I tried the following on Firefox, Opera, and Chrome. work fine:
#media only screen and (max-width: 975px) {
/* hide scrollbar on Firefox */
html {
scrollbar-width: none;
}
/* hide scrollbar on Chrom & Opera */
html::-webkit-scrollbar {
display: none;
width: 0px;
}
Related
In mobile view the navigation is all stacked up rather than in a line like the desktop template.
I would like the menu to be horizontal, the same way the desktop menu is, so it isn't taking up so much space.
/*************************************************
* Mobile Portrait *
*************************************************/
body {
overflow-x: hidden;
}
img {
max-width: 100%;
height:auto;
}
iframe {
max-width: 100%;
}
#media (max-width: 480px) {
.subscribe-box .block, .container {
width: 300px;
}
}
#media only screen and (max-width: 480px) {
.subscribe-box .block,.container {
width:320px;
}
.background-slider {
height: 320px !important;
}
#top-search{display:none}
#top-social {
float: right;
position: absolute;
z-index: 999999999999999;
right: 0;
}
#navigation-wrapper {
display:none;
}
.slicknav_menu {
display:block;
}
#logo img {
max-width:320px;
height:auto;
}
Are You asking for Menu in horizontal style.
If you are asking for horizontal menus style then you should search for Fletro menu in Google you will get a lot tutorial for that.
If I set the browser width to 1024px the following bootstrap container rule is being applied:
#media (min-width: 768px) {
.container {
width: 750px;
}
}
If I extend the browser width to 1092px then the following bootstrap container rule is being applied:
#media (min-width: 992px) {
.container {
width: 970px;
}
}
There are no other CSS rules applied to the container, just the standard bootstrap rules:
.container {
margin-right: auto;
margin-left: auto;
padding-left: 15px;
padding-right: 15px;
}
Can anyone explain to me why a browser width of 1024px isn't getting the min-width: 992px rules applied to it?
I think you forget open close bracket { }
#media (min-width: 768px) {
.container {
width: 750px;
background: yellow;
}
}
#media (min-width: 992px) {
.container {
width: 970px;
background: red;
}
}
I am trying to set the body and html to 100vh / 100% of my browser which works fine but once I get content that's longer than the original page it stops working with the background colors, which I can't make any sense of. I checked many posts on stackoverflow but can't seem to find the trick.
Here is a screen of my page, I made the background red for better visibility:
My code is inside an Angular 2 application with many different Sass files, but here is the code that sets up the menu/content area and wrappers.
#import "../assets/sass/variables";
body, html {
margin: 0;
padding: 0;
height: 100vh;
background-color: #f6f6f6;
}
body, .wrapper {
min-height: 100vh;
height: 100vh;
font-family: 'Roboto', sans-serif;
}
.hide {
display: none;
}
.show {
display: block;
}
.main-content-area {
position: relative;
z-index: 2;
float: right;
width: 100%;
min-height: 100vh;
height: 100vh;
background-color: red;
}
.dont-break-out {
/* These are technically the same, but use both */
overflow-wrap: break-word;
word-wrap: break-word;
-ms-word-break: break-all;
/* This is the dangerous one in WebKit, as it breaks things wherever */
word-break: break-all;
/* Instead use this non-standard one: */
word-break: break-word;
/* Adds a hyphen where the word breaks, if supported (No Blink) */
-ms-hyphens: auto;
-moz-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
#media (min-width: 576px) {
.main-content-area {
width: calc(100% - 50px);
}
}
#media (min-width: 768px) {
.container {
width: 718px;
}
}
#media (min-width: 992px) {
.main-content-area {
width: calc(100% - 200px);
}
.container {
width: 792px;
}
}
#media (min-width: 1200px) {
.container {
width: 1000px;
}
}
#media (min-width: 1400px) {
.container {
width: 1170px;
}
}
I hope anyone had a similar issue before. Note that my content area is continuing after the red background and menu background. Any help will be greatly appreciated. Cheers!
When using brackets to code my website, the #media worked and would make divs appear and disappear to support mobile screens. But after uploading to my hosting site, it does not work and all the elements are showing at once. How can I fix this? The relevant CSS code is below.
CSS:
#media (max-width : 720px) {
.disappear {
display: none;
}
#menuposition {
margin-left: auto;
margin-right: auto;
}
.galleryitem {
width: 100%
}
.containergallery {
max-width: 250px;
padding-top: 0%;
}
}
#media (min-width : 721px) {
.reappear {
display: none;
}
#menuposition {
right: 0px;
position: absolute;
}
}
#media (max-width : 960px) {
.galleryitem {
width:100%
}
.containergallery {
max-width: 300px;
padding-top: 10px;
}
}
That page you linked to doesn't have that CSS in the source anywhere and none of the linked files have it either.
Link the CSS to the page or place it in an inline-style element.
I want to use a mediaquerie for max-width. It works fine with Chrome but in Firefox it does not, why?
jsfiddle code
CSS
.box {
width: 150px;
height: 150px;
background-color: blue;
}
#media screen and(max-width: 400px){
.box {
background-color: red;
}
}
Your syntax is wrong, you need a space between and(max-width)
See below
#media screen and (max-width: 400px){
.box {
background-color: red;
}
}
JSFIDDLE
There is no closing bracket in your above #media rule -
.box{
width: 150px;
height: 150px;
background-color: blue;
}
#media screen and (max-width: 400px){
.box{
background-color: red;
}
} /* END THIS #MEDIA RULE */
I like to do something really obvious like this to remind me ---
You don't need the "and" - or the "screen"
#media (min-width: 30em){ /* ============ */
body {
background-color: red;
}
} /* === END MEDIUM BREAK =============== */