Applying Styles in media queries which has same width but different height - html

So I am facing problem with where I have 2 different mediaqueries where the width is same for each but the height is different like this:
#media only screen and (max-width:1920px) and (min-height:1080px){
#home{
height:1080px;
}
}
#media only screen and (max-width:1920px) and (min-height:1200px){
#home{
height:1200px;
}
}
But what happens is that when I change the screen dimensions to 1920px width with 1200px height it seems that this media query is not overriding the other one with a height of 1080px. For now I am stuck here and cant figure out the mistake I made. Whats the issue here ? Where am I going wrong ? what is the solution to this problem ? Thanks for your help !

The world 'screen' in the media queries is a little bit confusing. The actual meaning of it is not the computer screen resolution but the actual internal size of the browser window. Even when the window is maximized, to compute the actual height you should discount from the screen height the browser window caption address bar, system tray, etc., so if the screen resolution is 1200px then media query screen size will be something about 1180px.
The following code sample illustrates the concept. See it in full screen mode, try to resize the browser window and see how the color changes:
body{
background-color: yellow;
}
#media only screen and (max-width:1920px) and (min-height:500px){
body{
background-color: lime;
}
}
#media only screen and (max-width:1920px) and (min-height:800px){
body{
background-color: red;
}
}

Related

How can I make my container look nice on phone screens and not come out bad on desktop screens?

So I'm a newbie when it comes to bootstrap. I came across the web and found out that I can make my containers look the same on all screens by using this code?
#media (min-width: 1200px) {
.container-small {
width: 700px;
}
.container-large {
width: 1500px;
}
}
Can someone please explain this more to me and tell me how it works.
#media (min-width: 1200px) {
}
This tell to the PC, when the screen width is equal or less than 1200px the boxes you edited before in CSS are going to have a different behavior.
I mean if I have a div which width is 500px and, of course, in a cellphone doesn´t look good, you while using this metod of #media can change the size and behavior of your div and the elements that contains, without affect your original size in the desktop.
https://www.youtube.com/watch?v=6Yh8y0pVfQc&ab_channel=Flux
In this video is explained very well. I hope it can helped you!

Media queries not working when changing screen resolution but working when changing width and height google responsive developer tools checking

Hi am trying to apply the css when screen resolution is 1280*720 its not applied but when I manually enter width and height in google responsive check its working . Here is code of css
#media (min-height:720px) and (min-width: 1280px) {
.space
{
margin-top:24.5%;
}
}
You want it from 720px to 1280px then you have to use media query min-width:720px (i.e. from 720px) to max-width:1280px (i.e. less then 1280px) as below,
div {
width: 100px;
height: 100px;
background: #111;
}
#media screen and (min-width: 720px) and (max-width: 1280px) {
div {
background: red;
}
}
<div></div>
Scale your browser and see div background change.
On desktop systems, the size considered by media queries like min-height is the size of the content area of the browser, not the resolution of the screen. A system with a 1280x720 screen will not use rules in this media query unless the browser is in in full-screen mode, since some of the screen is being used for the browser toolbar and scrollbar, window decorations, a taskbar (on Windows) or menubar (on macOS), etc.

responsive - css parallax type - images not inside container

i am trying to build a site with basic css "parallax" effect where the image has a background-attachment:fixed and stays there when you scroll. the code background-size:cover works great in large browsers, but i am noticing when i make screen smaller, sizes 800px or 900px, the images in the div are getting cut off and i only see a little of the image. i've played with changing background-attachment to be background-attachment:contain - when i do that the image shows perfectly in the div but i see a huge space under the image.
http://greendental.mediaworksonline.com/
i've been wracking my brain on this for 2 days. if you could help that would be greatly appreciated. i'm building this to just use css and not jquery.
A fast solution can be put differents resolutions, an example
#media screen and (max-width: 900px) {
.imgblock {
min-height:400px;
}
}
#media screen and (max-width: 400px) {
.imgblock {
min-height:200px;
}
}
Hope this can help you

Display div only in high resolutions

I've made a website that stretch a container to the bottom. In that container, there are divs that fit perfectly the screen at low resolution such as 1366x768 ...etc
But when the resolution is higher (1440x900...etc) There is a blank space left under the divs (link to view website at different resolutions)
So is there a possibility to fill that space with divs only in high resolution ? I've tried overflow-y:hidden,but since the container's height must be in auto it doesn't affect it.
Use media queries that target resolution like
#media screen and (min-resolution: 300dpi) {
#myDiv{
display:block;
}
}
Alternatviely, you can target dimension such as width like
#media screen and (min-width: 1000px) {
#myDiv{
display:block;
}
}

How to make a div snap to min or max size, without any sizes in-between?

I recently saw a link, on twitter, to path's new website; with.me. There's some pretty simple but neat things occurring on a with.me page, for example look at this one of Ashton Kutcher:
http://with.me/w/2275
My favorite thing on that page is how the picture appears to snap to a minimum and maximum size. When you resize the browse, you will notice that the image will eventually shrink to a smaller size in a "snapping" fashion. It doesn't resize with the browser, it instantly goes to the smaller size if the bigger one can't fit in the browser window.
How are they doing this? I've been poking around the CSS for the past two hours. I have a test page of my own that I've been trying to get this to work on, but can't figure it out.
Any ideas?
#ryan; it's a css3 media query .
if the check the link source then you saw he you it in there css
#media screen and (max-height: 720px), screen and (max-width: 850px) {
#page.permalink {
height: 454px;
margin: -247px auto 0 auto;
}
#page-container {
width: 650px;
}
#photo-container {
margin-left:-370px;
}
#photo {
height: 454px;
width: 340px;
background-size: 340px 454px;
}
}
check this
http://css-tricks.com/css-media-queries/
It's done by applying different stylesheets based on screen size:
#media screen and (min-height: 1000px) {
If you're using a webkit-based browser (safari / chrome), it actually animates between the two using a webkit animation.