.remote-local-video {
display: grid;
grid-gap: 0.25rem;
grid-template-columns: 50% 50%;
grid-template-rows: 80vh;
grid-template-areas: "remoteVideo localVideo";
.ch-video {
object-fit: contain;
}
#media (max-width: 769px) {
grid-template-columns: 100%;
grid-template-rows: 40vh 40vh;
grid-template-areas: "remoteVideo" "localVideo";
}
}
We have this CSS. It seems to be working fine in Android Chrome, Chrome/Firefox dev tools in Macbook Pro. In iPhone 12 Max Pro, iPhone 11 Pro and IPhone XR - either remoteVideo is displayed or localVideo is displayed. Both are not displayed together. I tried this both in Chrome and Safari browser.
I have found that Safari on iPhone is more particular with having perfect code than any other platform. Could it be that the closing bracket for your class .remote-local-video is at the bottom of this CSS instead of above the .ch-video class? Also (not sure if you are just using different syntax than I am used to - but I usually separate the media query and re-state the class name within). I threw this in my testing environment real quick and found it working in Safari on iPhone 6:
.remote-local-video {
display: grid;
grid-gap: 0.25rem;
grid-template-columns: 50% 50%;
grid-template-rows: 80vh;
grid-template-areas: "remoteVideo localVideo";
}
.ch-video {
object-fit: contain;
}
#media only screen and (max-width: 769px) {
.remote-local-video {
grid-template-columns: 100%;
grid-template-rows: 40vh 40vh;
grid-template-areas: "remoteVideo" "localVideo";
}
}
Note: I also used the following HTML (please pardon my inline border for visibility):
<div class="remote-local-video">
<div style="border: 1px solid black">1</div>
<div style="border: 1px solid black">2</div>
</div>
(I once found a missing closing bracket in a JavaScript selector that was working everywhere else in a web application, but stopped working/showed up when the dept. switched to using iPhones!)
.remote-local-video {
display: grid;
grid-gap: 0.25rem;
grid-template-columns: 50% 50%;
grid-template-rows: calc(100vh - 80px);
grid-template-areas: "remoteVideo localVideo";
.ch-video {
object-fit: contain;
}
#media only screen and (max-width: 950px) and (orientation: portrait) {
div#meetingLocalVideo {
height: calc(50vh - 40px);
}
div#meetingRemoteVideos {
height: calc(50vh - 40px);
}
grid-template-columns: 100%;
grid-template-rows: calc(50vh - 40px) calc(50vh - 40px);
grid-template-areas: "remoteVideo" "localVideo";
}
#media only screen and (max-width: 950px) and (orientation: landscape) {
div#meetingLocalVideo {
height: calc(100vh - 80px);
}
div#meetingRemoteVideos {
height: calc(100vh - 80px);
}
grid-template-rows: calc(100vh - 80px);
}
}
IOS expects us to set explicit height of divs. Above CSS is working fine.
Related
I added media queries to my local wp-theme and the work fine locally. However, after I pushed the changes to staging site the media queries doesn't execute. Other changes not related to media queries work.
I checked the files through the staging wp-admin theme editor and the correct files are imported. But when I check dev tools on my staging site they media queries doesn't show at all. I use the same browser as my local environment, just different tabs. See screenshots of my local site and my staging site, in this example the div poem-card.
Local site, the width of the div is 88% as according to media query
Staging site, no media queries execute or even visible in the dev tool, width of div is 30%
I also pushed the code directly to my live site, skipping the staging part but it gave the same result there.
In my code I have this in my header
<meta name="viewport" content="width=device-width, initial-scale=1">
And here are my media queries and they work fine locally. I just can't find where the problem is, since it works locally in Wordpress I don't even know if it's a code thing.
#media only screen and (max-width: 600px) {
.poem-card {
width: 96%;
}
main {
padding:5px;
}
.site-header{
padding: 20px;
}
.article-bok {
display: flex;
flex-direction: column;
justify-content: space-evenly;
}
.text-bok {
width: 96%;
}
.bild-bok {
margin-top: 5px;
width: 96%;
}
ul {
padding-inline-start: 0;
}
}
/* Small devices (portrait tablets and large phones, 600px and up) */
#media only screen and (min-width: 600px) {
.poem-card {
width: 88%;
}
main {
padding:10px;
}
.text-dikt {
width: 80%;
}
.article-bok {
display: flex;
flex-direction: column;
justify-content: space-evenly;
}
.text-bok {
width: 96%;
}
.bild-bok {
margin-top: 5px;
width: 96%;
}
}
/* Medium devices (landscape tablets, 768px and up) */
#media only screen and (min-width: 768px) {
.poem-card {
width: 43%;
}
main {
padding:20px;
} }
/* Large devices (laptops/desktops, 992px and up) */
#media only screen and (min-width: 992px) {
.poem-card {
width: 28%;
}
.article-bok {
display: flex;
flex-direction: row;
justify-content: space-evenly;
}
.text-bok {
width: 40%;
}
.bild-bok {
margin-top: 40px;
width: 44%;
} }
So I am at the beginning, doing different tutorials and challenging myself with conquering the fundamentals. I know this might seem lowkey for most people but be gentle, i'm sorta new to this.
I tried using Media Queries 4 for example #media (30em <= width <= 50em ) { ... } but it jsut doesn't work for me (browser compatibility is checked btw) so I went with a classic code writing (which you may see below). Unfortunately my divs will not scale properly, I am clearly missing something like a parent-child not sharing the proper settings but I can't see it. Could you point out my mistake please? All it needs to do is scale the divs if the width is lower than 600, between 601 and 960 and above 961 (obv .px)
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* Mobile Styles */
#media only screen and (max-width: 600px) {
body {
background-color: #F09A9D;
}
}
/* Tablet Styles */
#media only screen and (min-width: 601px) and (max-width: 960px) {
.sign-up,
.feature-1,
.feature-2,
.feature-3 {
width: 50%;
}
}
/* Desktop Styles */
#media only screen and (min-width: 961px) {
.page {
width: 960px;
margin: 0 auto;
}
.feature-1,
.feature-2,
.feature-3 {
width: 33.3%;
}
.header {
height: 400px;
}
}
.page {
display: flex;
flex-wrap: wrap;
}
.section {
width: 100%;
height: 300px;
display: flex;
justify-content: center;
align-items: center;
}
.menu {
background-color: #5995DA;
height: 80px;
}
.header {
background-color: #B2D6FF;
}
.content {
background-color: #EAEDF0;
height: 600px;
}
.sign-up {
background-color: #D6E9FE;
}
.feature-1 {
background-color: #F5CF8E;
}
.feature-2 {
background-color: #F09A9D;
}
.feature-3 {
background-color: #C8C6FA;
}
The html is just a bunch of divs with an img src inside them. The output is the same no matter what the size of the browser window is.
#sbrrk is right. And also, you should write your media queries at the very bottom, so they will override other rules of the same specificity
I have a flex-box grid of divs.
I want to change width of that div (in %) depending on screen size.
My scss #media:
#media (max-width: 1023.9px) {
width: 33.3333%;
}
#media (max-width: 768px) {
width: 50%;
}
#media (max-width: 599px) {
width: 100%;
}
#media (min-width: 1024px) {
width: 25%;
}
But when I test that in Chrome's Responsive tool, I got only this:
Case of 500px width, It doesn't change,
When I change my screen size to 1020, it's OK, max-width: 1023.9px is working.
1200 is OK, min-width: 1024px is working. But less than 1024 - I get that strange things. What do I do wrong?
Generated css for my grid-class:
.image-grid {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
width: 100%;
background-color: #f6f6f6; }
.image-grid .image-wrapper {
width: 25%;
position: relative; }
.image-grid .image-wrapper::before {
display: block;
content: '';
width: 100%;
padding-top: 88.23529%; }
#media (max-width: 1023.9px) {
.image-grid .image-wrapper {
width: 33.3333%; } }
#media (max-width: 768px) {
.image-grid .image-wrapper {
width: 50%; } }
#media (max-width: 599px) {
.image-grid .image-wrapper {
width: 100%; } }
#media (min-width: 1024px) {
.image-grid .image-wrapper {
width: 25%; } }
Hmm, now It works fine when I resize my browser window, I normally get my 1 column with 550px and 2 columns with 700px. Question is answered, but in "Responsive" tool 550px and 700px still not working. Maybe I don't understand the tool.
Finally solved. The problem was totally dumb: I forgot adding meta tag, so Responsive tool didn't work properly. Don't forget about that important line. <meta name="viewport" content="width=device-width, initial-scale=1.0">
Every rule in CSS is able to override any previous rule to the same selector. So you just need to switch your code in order to get it working:
#media (max-width: 1023.9px) {
width: 33.3333%;
}
// experimental
#media (max-width: 1000px) {
width: 50%;
}
#media (max-width: 768px) {
width: 50%;
}
#media (max-width: 599px) {
width: 100%;
}
//
#media (min-width: 1024px) {
width: 25%;
}
The reason why your rules override each other is because they all have the same selector and while max-width: 599px is accurate and correct, the later appearing max-width: 1023.9px is it, too and thus it’s overriding the previous width: 100%; from the max-width: 599px media query.
And a side note here: Use integer values only for media queries. There is no screen in the world, which has .9 or even .5 pixels.
CSS is the acronym of Cascade Style Sheet.
This means that rules are matched in a cascade fashion. If you have a viewport width between 1000 and 1024, the 33.3333% is the last that matches and it will be applied, overriding all the previous.
Once you know it, you can change your code in a proper way. If you don't want to re-think your code, you can prevent the overriding using !important.
#media (max-width: 1000px) {
width: 50% !important;
}
Warning: Using !important is a bad practice, the reason is here
I want to reduce Jumbotron size for various screen sizes in Twitter Bootstrap (latest 3.x.x version). The viewport breakpoints do get triggered now e.g. for display: none on a section, but the Jumbotron size doesn't change. What's the problem here?
#media only screen and (max-width: 767px), only screen and (max-device-width: 767px) {
.jumbotron {
height: 30%;
height: 30vh;
}
}
and this being my usual settings
.jumbotron {
padding-left: 50px;
padding-right: 50px;
background: #41A4DA;
margin-bottom: 0px;
min-height: 70%;
min-height: 70vh;
display: flex;
align-items: center;
}
min-height remains 70vh, height tries to be 30vh,
putting min-height in media query block should work.
Also, please make sure that #media query block is parsed after .jumbotron class in the css file.
https://www.w3schools.com/cssref/pr_dim_min-height.asp
Hello guys I am using the following code to show and hide some elements but it seems to doesn't work on mobile devices.
#media screen and (max-width: 768px) and (orientation : portrait) {
.drawer1 {
display: block;
top: 789px;
}
.drawer {
display: none;
}
.drawer1-content {
background: #fff;
background-repeat: no-repeat;
border-collapse: collapse;
height: 645px;
width: 100%;
}
}
#media screen and (min-width: 769px) {
.drawer {
bottom: 0px;
height: 700px;
overflow: hidden;
position: absolute;
width: 1024px;
z-index: 5;
}
.drawer1 {
display: block;
}
..from the code you posted, looks like you miss a } at the end..
Also check if your device has a width less than 768px in the first case
and it has a width more than 769px in the second case (landscape or portrait)
try one of the several extensions available on Chrome/Firefox/Opera to set the max width of the viewport and simulate a mobile device..
From the comment:
so from the specs: IPAD 3gen: 2048-by-1536 pixel....here you have your answer :D just change the max-width and min-width ..or just use the landscape and portrait attributes