Display div only in high resolutions - html

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;
}
}

Related

Why some full screen website width do not match my screen width?

I use a 1920px wide screen. But when I inspect the html tag with chrome devtools on websites such as firebase or facebook messenger, this is what I see :
But these websites appear fullscreen, so I expected them to match my screen width.
Why is there a difference between my screen width (1920px) and the html tag width (1440px) and how to achieve this ?
If you set the width of the body of your HTML to a fixed width of 1440px, it will be 1440px even if the user screen is bigger or smaller than this. What you can do is set width to width: 100%; and a max-width: 1440px. That would make the size of the body to be the size of the screen if the screen is smaller than 1440px and 1440px if the screen is larger or equals to 1440px.
If I understood correctly what you are asking, you have a sidebar menu and a dashboard that needs to fullfill the screen. In that case, you could do:
.side-menu {
width: 20%;
}
.dashboard {
width: 80%;
max-width: 1440px;
}
#media (min-width: 1500px) {
.side-menu {
width: 100%
}
}
Using media-query makes you set different CSS properties for the elements in your HTML, depending, in this example, of the screen size. What I did: if the screen size is smaller than 1440px, the sidebar fills 20% of it and the dashboard fills 80%. If the screen size is bigger or equals to 1500px (a little big bigger than the max-width of the dashboard, to fit the sidebar also), the dashboard stays at 1440px and the sidebar fills the rest of the screen width (width: 100% makes the sidebar takes all the width that is left of the body).
Obviously in bigger websites such as Facebook etc it's a much more complex thinking than just CSS, because they have to consider the data flow, the device the person is using and many other things.
Either you have setup a DPI scaling on your PC or have the zoom level in your browser to something higher than 100%

Change layout based on screen size

I would like the content of my website header to occupy 100% of the screen width on regular-sized desktops/laptops, but to be centered on larger displays. By "larger displays", I'm referring to the actual size of the display too, not just the resolution. On my 15" laptop and my 23" desktop (both having the same resolution of 1920x1080), I would like the displays to be different. Having such a wide menu on a 23" display doesn't look good as there are wide empty parts.
I'm currently using a .container BootStrap class for the contents of the header, and I overrided a media query so that the container has a width of 100% when the screen width exceeds 1200px. Again, this isn't really what I want :
If the screen width exceeds 1200px, the header width should be 100%
If the screen width exceeds 1920px, the header width should be the default one, and the header should be centered
If the screen width exceeds 1200px, and the screen itself is large (anything above 19"), the header width should be the default one, and the header should be centered.
I'm not sure if that's the best approach, but I'm open to all suggestions.
Thanks
My solution was to use media queries based on pixel density
This allowed to write something like
#media screen and (max-resolution: 116dpi){
116dpi is the DPI of a 19" screen with a resolution of 1920x1080. If the screen gets larger, say 23" with the same resolution, pixel density gets lower, then we have something below 116dpi.
Try out setting media screen and limitation through min-width.
http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
#media screen and (min-width: 1200px) {
.container {
width: 100%;
}
}
#media screen and (min-width: 1920px) {
.container {
width: 500px;
}
}

Center main container for large screens in bootstrap

I am picking up an existing free template Jessicawhite at html5xcss3.com
I notice the images stretch 100% in any screen and in large screen (MAC wide screen for e.g.), it looks really ugly especially the home page slider.
I want to center the whole page/body if the screen is larger than the max size of my images (1280px, sized in the server) like in this site: igihe.com I tried playing with bootstrap-responsive.css. The highest screen it deals with is 1200px min.
#media (min-width: 1200px) {
}
My attempt was for screens with minimum 1400px:
#media (max-width: 1200px) {
//leave original intact
}
#media (min-width: 1400px) {
body {width:1366px; margin:0 auto;}
/* OR */
.body_container {width:1366px; margin:0 auto;}
}
As well, I just tried changing the min-width:1200px to min-width:1400px but it doesn't behave well either.
My issues are: it doesn't correctly react. My screen size is 1366px, which is less than 1400px yet it applies the body styles.
Need i add all the specs under each media to each screen size after words? Meaning, the min-width:1200px contains a bunch of specs. Does that mean each screen size has to define it?
Any shorter solution that puts the menu in consideration?
You can just use the simple css3.
use a wrapper division o wrap all your elements and this wrapper have a display:none; by default for all width of media.
.wrapper{
display:none;
width:your-width-num px;
margin-right:auto;
margin-left:auto;
}
And for the wider screens:
#meida(min-width:your-width-num) {
.wrapper{
display:block;
}
}

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

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;
}
}

Is it possible to both catch browsers width and still adjust the content when browser is made smaller

Here is an example. If I, for example, set body to 70em and then adjust the browser width this rule
#media only screen and (min-width: 481px) and (max-width: 1024px)
{
body
{
background : #B0E0E6 url(img/bg.jpg) no-repeat;
}
}
is true when the width is between 481px and 1024px.
But when I have the width:70em given in body the content is not being adjusted when I make the width for the browser smaller.
If I now change a little and set the width in the body to be 80% now the content is automatically being smaller when the width of the browser is smaller.
It seems to me that it's not possible to both being able to catch when the browser is for example between 481px and 1024px and at the same time shall the content being able to be smaller when the browser width is made smaller.
So my question is if it's possible to both being able to catch when the width of the browser is between 481px and 1024px and at the same adjust the content automatically being adjusted when the width of the browser
You set the width to 70em. That's a fixed width (more or less considering it's based on font size). Within the media query you do not set the width anywhere. You just set the background. You would need to adjust the width of the object you want to resize within the media query. So if you have
body{
width:70em;
}
#media only screen and (min-width: 481px) and (max-width: 1024px)
{
body
{
background : #B0E0E6 url(img/bg.jpg) no-repeat;
width: 50em;
}
}
That would resize the body based on the media query that you specify. Also, you may wish to look up CSS units to make sure you want to use em (because by your description, % may work for your needs): http://www.w3schools.com/cssref/css_units.asp