Windows 10 scaling default above 100% causing website sizing issues - css

So the client isn't happy with how their site is rendering on their laptop because Windows scaling (not to be confused with browser zoom) is set to 125% by default. The site isn't broken but they don't like the overall level of zoom.
After a bit of research, it looks like a recommended and default scaling above 100% is not unusual on some laptops (especially newer laptops with their higher pixel density). It has been suggested to me that converting all px based CSS to rems (which is a big job) might be able to fix this. However, I've run a test using a base font size of 10px and then rems for breakpoints and for fonts and it doesn't look any better when I switch between different scales.
To my mind, if the OS is set to scale greater than 100% then everything, websites included, will display accordingly. I'm wondering if I am missing something here? I happen to be working from a very crappy old low res screen so perhaps this is a confounding factor?
fiddle using rem
html {
font: 10px;
}
.wrapper {
display: flex;
justify-content: center;
.inner {
flex: 1;
padding: 1rem 2rem;
background: hotpink;
p {
font-size: 1.6rem;
}
}
}
#media (min-width: 60rem) {
html {
font-size: 16px;
}
.wrapper {
.inner {
flex: 0 1 50rem;
background: goldenrod;
p{
font-size: 1.125rem;
}
}
}
}
and fiddle using px
font: 16px;
}
.wrapper {
display: flex;
justify-content: center;
.inner {
flex: 1;
padding: 10px 20px;
background: hotpink;
p {
font-size: 16px;
}
}
}
#media (min-width: 600px) {
.wrapper {
.inner {
flex: 0 1 800px;
background: goldenrod;
p {
font-size: 18px;
}
}
}
}
Is there a solution?
Thanks

Because of your client's device pixel ratio, website is probably serving an unexpected responsive version to their screen "real" width.
For example: assuming you're using breakpoints like Bootstrap's ones, if their monitor has a resolution width of 1200px (extra large device) but scaling is set to 125%, browser will zoom everything out to 80% and make website serves the version corresponding to a screen width of 960px (large device).
(See this site to test "true" and adjusted sizes to a monitor.)
Depending of how your website is builded, you could workaround this by:
(1) Adjusting viewport width with JS, in a similar way to what was proposed in this thread:
document.querySelector("meta[name=viewport]").setAttribute('content', 'width=device-width, initial-scale='+(1/window.devicePixelRatio));
(2) Tweaking your stylesheet to make breakpoints reflect real device width:
#media (min-width: 1200px), (min-width: 960px) and (-webkit-device-pixel-ratio: 1.25) {
/* your code here */
}
Or even detecting your client's specific pixel ratio and then zooming everything out, like that:
#media (-webkit-device-pixel-ratio: 1.25) {
* {
zoom: 0.8;
}
}
(Please note that in these scenarios you'd need to use a non-standard, although well supported #media feature.)

Related

Scaling a complex responsive header [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I'm practicing the one thing that scares the hell out of me: responsive CSS.
I made a header like this one, mostly via use of positive/negative margins. However, it becomes a mess once I start changing the viewport's dimensions.
Were it just a simple h1 (such as only the 'Grandmaster'), I'd use font-size: 5vw, and it'd scale. However, since it's more complex, just throwing vw units around doesn't help.
What is the best way to have a complex header like this scale well across all screen sizes?
My idea:
Make it either a SVG or a JPG, then have a h1 with display:none or some other trick (such as moving it off screen with position:absolute) for SEO. The pro is that making it an image is probably the easiest way to let it scale everywhere properly. The con is that, as far as I'm concerned, it still hurts SEO.
Is there one estabilished way to deal with such a case?
There are many strategies you could go about this one, since it is very opinionated, the best solution would be to keep the text, use some span for the various parts of the text and use em units to size them, then just change the font-size on the parent element and the various parts will scale accordingly. Use media queries #media to change the parent element's font-size in critical breakpoints.
body {
margin: 0;
}
.header__title--content {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 50px 0;
background-color: red;
background: url('https://picsum.photos/2000?grayscale');
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
font-family: 'Times New Roman', serif;
}
#media screen and (min-width: 400px) {
.header__title--content {
font-size: 3em;
}
}
#media screen and (min-width: 800px) {
.header__title--content {
font-size: 4em;
}
}
#media screen and (min-width: 1000px) {
.header__title--content {
font-size: 6em;
}
}
.header__title {
display: grid;
margin-bottom: 0.1em;
}
.header__title--element-one {
font-size: .75em;
margin-left: 1.7em;
line-height: .9em;
}
.header__title--element-two {
font-size: .5em;
margin-left: 2.5em;
line-height: .6em;
}
.header__title--element-three {
font-size: 1em;
line-height: .6em;
}
.header__subtitle {
font-size: .4em;
text-transform: uppercase;
line-height: 1em;
}
<hgroup class="header__title--content">
<h1 class="header__title"><span class="header__title--element-one">Story </span><span class="header__title--element-two">of the </span><span class="header__title--element-three">Grandmaster</span></h1>
<h2 class="header__subtitle">bobby fisher, the some content goes here</h2>
</hgroup>
try using css media queries for example:
h1{
font-size: 30px
}
#media screen and (max-width: 790px) {
h1{
font-size: 15px
}
}
#media screen and (max-width: 790px) this means For screens that are 790px or less, set the font size to 15 px you can read more about it here https://www.w3schools.com/css/css_rwd_mediaqueries.asp

Issue with max-width and the relative sizes of elements across devices

I have an issue with a media query. Using the following HTML and CSS, the b-class element is supposed to narrow to 128px when the window narrows to the point it would otherwise overlap with the a-class element (roughly). This works on my 3000x2000 laptop display, but in Firefox on my mobile in landscape mode, the elements overlap without the media query rule kicking in.
Example code: codepen.io/krainert/pen/KKzVQLPcode below
<p class="a">Here is a headline</p>
<p class="b">Here is a nav element with several menu items</p>
body, p {
margin: 0;
font-family: 'calibri';
}
.a {
font-size: 50px;
background-color: blue;
}
.b {
position: absolute;
top: 0px;
right: 0px;
font-size: 24px;
background-color: red;
}
#media only screen and (max-width: 832px) {
.b {
width: 128px;
}
}
I reckon this is caused by discrepancies between differences in device-width and the screen-relative sizes of elements across devices -- that is to say, the difference between device-width on mobile to that on my laptop is greater than the difference between the widths of the elements on mobile to those on my laptop relative to the sizes of their screens. Or maybe I'm confusing myself. What's the best way to fix it?
Try limiting the width of the .a container, so they don't overlap:
#media only screen and (max-width: 832px) {
.b {
width: 128px;
}
.a {
width: calc(100vw - 128px);
}
}

WP - Contact form 7 - Input & Btn next to each other

here my website I´m working on: http://www.whatsahoy.com/
My problem: I want the input field next to the button. If I add a float left, it goes next to each other but with a weird <br>. And then the whole thing is also on the left. I want it to be in the middle.
Can somebody help me please?! Thank you very much!
Barbara
To provide you with the best solution, it would be helpful to see the source code of your form. The <br> is probably in there somewhere. However, here is my reply based on what I can see. If it does not help, I suggest you update your question.
Adding the following styles to your custom CSS will put the field and button next to eachother until screen width of 767px.
.wpcf7-form p {
display: inline-block;
width: 470px;
max-width: 95%;
}
.wpcf7-form p br {
display: none;
}
If you would like them next to eachother on smaller screens, you could change the width of the frame. This changes on 767px as set by your theme. I'm not sure this will not have an undesired effect elsewhere on your site, but you could try.
#media only screen and ( max-width: 767px ) {
.et_pb_row {
width: 600px;
}
}
However, it then will be crippled on screens as from 600px. It may be better to make the text field smaller then...
#media only screen and ( max-width: 600px ) {
.wpcf7 input {
max-width: 50%;
}
}
You might want to fine tune this a bit, but I hope you get the idea.
GL!
.wpcf7-form-control-wrap {
display: inline-block !important;
margin: -8px;
}
form.wpcf7-form.init.mailchimp-ext-0\.5\.55 {
display: flex !important;
justify-content: center !important;
}
input.wpcf7-form-control.has-spinner.wpcf7-submit {
border-radius:0px !important;
width: 30%;
}
#media only screen and (min-width: 50px) and (max-width: 600px) {
div#wpcf7-f698-p10-o1 {
width: 130%;
}
#media only screen and (min-width: 50px) and (max-width: 600px) {
input.wpcf7-form-control.wpcf7-text.wpcf7-email.wpcf7-validates-as-required.wpcf7-validates-as-email {
width: 235px;
}
form.wpcf7-form.init.mailchimp-ext-0\.5\.55 {
display: flex !important;
padding-right: 70px;
}}

Floating thumbnails with :nth-child CSS skipping a column

I have a gallery of floated thumbnails which I'd like flush against both sides of the containing div, but with whitespace between them.
JSfiddle of the desired behaviour.
Relevant CSS:
.thumb {
display: block;
float: left;
width: calc((100% - 72px)/3);
margin-top: 18px;
margin-right: 36px;
transition: opacity 750ms ease-in-out;
}
#media screen and (max-width: 1553px) {
.thumb:nth-child(3n+3) {
margin-right: 0;
}
}
#media screen and (min-width: 1554px) and (max-width: 2059px) {
.thumb {
width: calc((100% - 108px)/4);
}
.thumb:nth-child(4n+4) {
margin-right: 0;
}
}
#media screen and (min-width: 2060px) {
.thumb {
width: calc((100% - 144px)/5);
}
.thumb:nth-child(5n+5) {
margin-right: 0;
}
}
In Chrome and Firefox on OSX, at some resolutions (such as 1024px), the thirteenth thumbnail centres itself in the container and puts all the :nth-child styles out of whack, breaking the layout below. I've changed the order of the thumbnails, but it's always the thirteenth one. Thinking it may have something to do with fractions of pixels resulting from the calc() division, I subtracted 1px from the width of the thumbnails, with no luck either.
I don't see any relevant difference between what I've done in the JSfiddle and the WIP site. What am I doing wrong?
Well it's not your real answer, but i think you are getting hard to your self!
There are very cool and easy ways to create what you want.
I recommend you to read more about Foundation Block Grid and FlexBox.
don't try to reinvent the wheel.

Why don't CSS media queries follow the normal conventions of inheritance and cascade?

I've been having some issues with my CSS3 media queries...
Here's a small snippet of one I'm currently working on:
#media only screen
and (max-width : 420px) {
.page { min-width: 300px; max-width: 480px; width: 100%; }
.page .alpha { font-size: 2em; }
/* Set-up the column */
.page .column { margin: 0 auto 2%; width: auto; }
.page .gallery .column { min-height: 470px; height: auto; padding: 2%; }
}
/* Increase the main title for slightly larger screens! */
#media only screen
and (max-width : 480px) {
.page .alpha { font-size: 3em; }
}
I'm working from a 'mobile first' standpoint and given the normal behaviour of CSS regarding the 'cascading' aspect I would expect the second #media statement to inherit all of the styles from the previous statement, whilst overriding any for which it has a matching or 'heavier' selector.
(Plus CSS's order of precedence would mean any matching style definitions would use the last defined rule-set unless 'trumped' with an !important statement!)
From what I've seen though, through testing and some Google / SE searches this is not the case.
Is it possible for #media style rules to inherit from applicable earlier statements or am I stuck with having to repeat all the rules I need for each statement? (not very DRY)
I'd really appreciate any help and clarifications / explanations for this.
Firstly thanks #BoltClock (for both comments), and to the other comments and answers for all your help.
I think I made a mistake in my media queries and/or was miss-understanding how they worked and interacted together. I was going to edit my question with the following but decided it would make more sense as an answer (since it's the solution I used). I apologise if this has wasted anyone else's time.
Here's my fixed snippet of code:
#media only screen
and (max-width : 480px) {
.page { min-width: 300px; max-width: 480px; width: 100%; }
.page .alpha { font-size: 2em; }
/* Set-up the column */
.page .column { margin: 0 auto 2%; width: auto; }
.page .gallery .column { min-height: 470px; height: auto; padding: 2%; }
}
/* Increase the main title for slightly larger screens! */
#media only screen
and (min-width : 421px)
and (max-width : 480px) {
.page .alpha { font-size: 3em; }
}
I realised from your comments that if I increased the max-width in my first block to cover the necessary range/limit I could then either nest or add the second block after it (I tried both and they both worked for me -- using chromium browser [18.0.1025.151]). This successfully gave me the desired result, in that the page .alpha element's font size increased at the required stepping/interval.
Thanks again for all SO'ers who helped!
(and to SE for the awesome communities they've helped build)
Knowledge > OpenSource > Freedom
If you want to work from mobile up, you will need to set the mobile layout as the default layout. (Remove the query). From there the queries will inherit from above.
.page { min-width: 300px; max-width: 480px; width: 100%; }
.page .alpha { font-size: 2em; }
/* Set-up the column */
.page .column { margin: 0 auto 2%; width: auto; }
.page .gallery .column { min-height: 470px; height: auto; padding: 2%; }
/* Increase the main title for slightly larger screens! */
#media only screen
and (max-width : 480px) {
.page .alpha { font-size: 3em; }
}

Resources