Zooming versus change in window width - html

With all my reading on zooming with css, I have reached the conclusion that it's not really a good idea considering the limited support of zooming with all Browsers. In this regard, I cannot help but notice that Microsoft's WORD does not zoom the contents of the Word documents. Maybe they're right.
But let me trudge on ...
As a learning experience, what I'd really like to see with zooming is
= exactly what happens when re-sizing the Browser window. That is, element containers + font sizes + etc, shrink when contracting the window size (zoom out) and expand when increasing the window size (zoom in).
But, still maintaining the layout UNTIL a certain limit; e.g., when the width of the round corner box reaches a certain width say 80% of the device's width
For example:
BTW, the above is all block centered.
For example, the width rounded corner box increases with a bigger window = zoom in, and the box's width decreases with a smaller window
= zoom out.
I wish ditto for zooming, but zooming withOUT changing the window width, i.e., just for the contents of the window.
WHAT DOES HAPPEN:
with zooming in, everything appears to be doing well
with zooming out, okay UNTIL a couple of CMD-plus's. At this point, the rounded corner border shifts right and beyond the view of the Browser window and the super ugly horizontal scroll bar appears.
HTML:
<section class="roundedBodyCornersWrapper zoomStyleRule centerBlock elemPadding">
<div class="roundedBodyCorners">
<img class="headerImage centerImage" src="images/Broken_Heart.gif" alt="crying" />
<section class="roundedTextCornersWrapper centerBlock elemPadding">
CSS:
body {
background-color: white; /* around oval */
margin: 2.0em;
font-size: 120%;
min-width: 300px;
}
.zoomStyleRule {
width: 75%; /* always put fall-back spec 1st */
width: auto\9; /* IE8 = exception to fall-back spec */
width: 75vw; /* even if this isn't here, still does not work */
height: auto;
}
.roundedBodyCornersWrapper {
/* center via .centerBlock in layout */
/* padding via .elemPadding in layout */
}
.roundedTextCornersWrapper {
padding-bottom: 2.0em; /* + a tad extra above .mainContent */
}
.headerImage {
/*
original size = 888px X 448px (55.5em X 28em)
*/
width: 75%;
width: auto\9; /* IE8 exception */
padding-bottom: 1.5em;
}
.centerBlock, .centerImage {
display: block;
margin-left: auto;
margin-right: auto;
}
.infoHeader {
font-family: Georgia, Helvetica;
font-size: 130%; /* 130% x the % in body */
color: #fff;
}
BTW, everything does not work as already described even when I have
<meta name="viewport" ...>
and
#viewport {
}
appropriately placed.
In the interests of total disclosure, I am no longer certain of what dimensions change when the window resizes or when zooming out/in occur. I see the GUI changes ...

Oh, for Heaven's Sake ...
body {
background-color: white; /* around oval */
margin: 1.0em;
font-size: 120%;
/*
min-width: 300px; // Oh ... for Heaven's Sake!!!
*/
}
WHY does the elimination of min-width eliminate my zooming problems??

Related

How to avoid horizontal scroll on website

I recently made a tribute page using html and CSS. The website looks fine on desktop but on mobile,a horizontal scroll bar appears and make the website look left aligned.I think its because the images exceed the parent container but I am unable to fix it.
Github pages: https://rahulviveknair.github.io/Coldplay-Tribute-Page/
Code hosted on github: https://github.com/RahulVivekNair/Coldplay-Tribute-Page
The code used to adjust image but does not seem to be working
#image {
max-width: 100%;
display: block;
height: auto;
margin: 0 auto;
}
I would suggest you to do the following:
remove margin and padding from the body, and set its width to 100%, in order not to rely on the default width applied by the browser:
body{padding:0; margin:0; width:100%;}
set a max-width if the disks cover:
#image-grid img {max-width: 100%;}
change the font-size of the title with media query:
#media screen and (max-width: 600px) {
h1 { font-size: 30px; }
}
The scrollbar only appears when your header "COLDPLAY" is getting too big/wide, which is due to its font-size. So you should use a media query for #title or h1 where you define a smaller font-size setting.
Try also wen do debugging to unable cache in DevTools(if you use Chrome).
Usually files are not updating and you don't see any result even if you change something.
Also check this page if you are beginner CSS Tricks
P.S. I also started with CodeCamp good luck on next assignments
Remove both #media for the h1 and replace them with:
h1 {
font-family: 'Montserrat', sans-serif;
font-size: calc(5vmin + 16px); /* (320,32)(1280,80) */
font-weight: 600;
text-align: center;
margin-bottom: -15px;
}
This calc() calculates the h1.font-size using linear equation y=mx+b (MathIsFun: linear equation) with points
point1 x1=320px y1=32px, fontsize 32px on a 320px display
point2 x2=1280px y2=80px, fontsize 80px on a 1280px display
and all h1.font-size for all display sizes inbetween/beyond (I tested this with your Codepen).
Did the same trick with the 'album' images by adding column-count and column-width
#image-grid {
column-count: 3;
column-width: calc(8.75vw + 252px); /* (320,280)(1920,420) */
...
}
Finally change CSS #image { max-width: 100% } to img { width: 100% } and all the images on the page resize responsively
See my Codepen
Note anything smaller than 320x320 can be considered a 'smartwatch'!
It's really easy, all you need to do is set the overflow-x value to hidden, if you only want to avoid a horizontal scrollbar and not a vertical one.
However, this will cut off things that go beyond the scrollbar, so you need to fix those widths as well.

Literally canvas on mobiles in landscape mode

Is there a built in solution to get round the min-height: 400px; that is applied to literally canvas? - not override it but reduce margins/padding within the interface or swap out the menu buttons for smaller one? Literally canvas seems to not be able to display on most mobiles in landscape - which is a shame because it looks like its about 40-60px off.
Literally canvas uses a class called .literally on its wrapper div so to minimise the interface (all the buttons etc.) a little more when fullscreen for a mobile's landscape screen I did this:
:fullscreen .literally *
{
margin-top: 0px !important;
margin-bottom: 1px !important;
padding: 0px !important;
line-height: 100% !important;
}
Then for the literally canvas div, I reset the min-height as follows:
:fullscreen .literally
{
width: 100%;
height: auto;
min-height: 325 !important; /* reduce literally canvas's min-height */
}
This reduces the app more than enough to fit.

Content overflowing / overlapping flex items on smaller screens

I'm using flexbox and I set each section's height to 100vh.
Whenever, I resize the window, the text from the first section and the last section overflow to the other sections.
.banner, #showcase {
display: flex;
align-items: center;
justify-content: center;
}
.container, .banner {
width: 100%;
height: 100vh;
}
http://codepen.io/mrfishball/pen/oLgLxX
have you tried overflow:hidden; on the sections where the content is overlapping?
.banner, #showcase {
display: -webkit-flex;
display: flex;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
/**border: 10px blue solid;**/
overflow: hidden; /*or scroll*/
}
And you can control the font size for different device screen sizes. For example:
#media only screen and (max-width: 500px) {
.banner {
font-size: 9px;
}
}
you can just add width : 100% to .content
I've been struggling with the same issue over the past few days, and after hours of Google, trial and error, I have come up with a good workaround for one of your issues. I'm still struggling with the positioning a little so I'm not going to touch on that, but figuring out how to implement fluid typography REALLY helped me with the overflow problem.
I'm not going to try explain it all in detail, because it the resources I'm linking below do a much more thorough job, and there might be information I am unaware of/misunderstood.
The TL;DR of it is that instead of a bunch of media queries, you want the text to fluidly scale to your viewport size. Here are the basic steps, but first, a disclaimer:
Test this out on a sandboxed version of your site if possible. It might take you a while to get to the ideal typographic scaling, and
you will negatively affect your customer experience if every few
minutes the text size changes.
Set your base font size to 100% (either in body or html, depending on how your site is set up)
html {font-size:100%;}
Set your typographical hierarchy in rem (not em) sizes (rem works off the base font size, making the math simpler). For example:
p { font-size: 1.25rem; }
h1 { font-size: 4rem; }
h2 { font-size: 3.25rem; }
h3 { font-size: 3.0rem; }
h4 { font-size: 2.75rem; }
h5 { font-size: 2.25rem; }
h6 { font-size: 1.75rem; }
Add the following two media queries to enable the responsive behaviour of the text, and to settle the size above a specific threshold:
#media only screen and (min-width: 10em) {
html {
font-size: calc(0.875em + 0.25 * (100vw - 80em) / 40); /* 1 */
font-size: -webkit-calc(87.5% + 0.25 * (100vw - 8000%) / 40); /* 2 */
font-size: -ms-calc(0.875em + 0.25 * (100vw - 80em) / 40); /* 3 */
}
}
#media only screen and (min-width: 120em) {
html { font-size: 1.125em; }
}
And Voila! You should have fluid typography! You will have to go through your site carefully and make sure there aren't things overriding your css (bootstrap screwed me for hours before I finally clicked, thanks to the Google Developer sidebar), and that you don't have rogue font-size declarations messing up your pretty layout. If your site is clean and your typography well laid out though, you should be able to carry on just using <p>, <h1> and so on tags, all of which will be fully responsive.
Here are a few resources I found extremely helpful in figuring this out:
https://zellwk.com/blog/viewport-based-typography/
https://www.smashingmagazine.com/2016/05/fluid-typography/
You set this height: 100vh; and that's what's causing the problem. Set it to 100%.
.container, .banner {
width: 100%;
height: 100%;
/**border: 10px black solid;**/
}
I see other answers include adding more viewport height to child elements, but I think that's asking for more trouble. Plus, it doesn't entirely solve the overlapping issue. I usually avoid vh or vw unless it's necessary to achieve something that cannot be done with them; for example, parallax scrolling or side navigation with enhanced entrance and leaving animation.
To achieve a clear cut, bullet proof sections without any overlapping, use height: 100%;
Update: I am not able to comment since I don't have enough points, so I am adding it here. In response to this comment "#StevenKwok, I updated the answer. You can search more about responsiveness and screen sizes", this supports my point, asking for more trouble. If you stick with vh, then you will need to add media queries at certain breakpoints, including small laptop, tablet, and mobile devices.

Logo Height not responsive

The "rh" logo on my site is responsive vertically, ie fits perfectly to a tall thin window, but does not resize to a wide short window. Could anyone help me make the logo responsive to both width and height?
here is the website... (takes a bit to load up)
http://rhwebdesign.co.uk/
Here is my CSS:
img {
height: auto;
max-width: 100%;
vertical-align: middle;
}
To be very specific and address your questions about the logo, consider setting the max-height relative to the window's height.
You have:
img {
height: auto;
max-width: 100%;
vertical-align: middle;
}
.hero-logo img {
max-width: 100%;
min-height: 100%;
padding: 20px;
}
In order to scale the logo, add in to the latter block:
max-height: 100vh;
This sets the images maximum height to 100% of the viewport height, which appears to be what you desire here. Note that there is some text beneath it, which is not displayed, since it is text wrapped in an H5. These two lines are 68px tall (40px padding plus 28px for the text). So, you can adjust the above to:
max-height: calc(100vh - 68px);
It looks like in landscape mode (480x320), there is a script not calculating the size of margin correctly.
<div class="container hero-content" style="margin-top: -97.5px;">
have a look in main.js for this function:
heroContent.css({
"margin-top" : topContentMargin+"px"
});
Which is this:
topContentMargin = (heroHeight - contentHeight) / 2,
heroHeight = windowHeight,
contentHeight = heroContent.height(),
I haven't really looked into why it is calulating it incorrectly. My guess is that heroContent is too high for landscape mode because the image becomes 441px high with the media query max-width:100%. So it tries to add a negative margin to compensate.
My advice would be to remove the jQuery calculation of the hero content sizing and apply sizes using css and media queries only.
Edit:
You need to be more specific with your css. Learn some more about css specifity. You should include your largest media queries at the top, so the smaller ones will take precedence at the bottom. Makes things easier. Also IMHO, I wouldn't use queries for anything larger than iPad. ie. 1024px. Although you should always test on newer devices if possible.
You will need to specify the height of the video for each specific device size. I can't tell now, but maybe jquery was determining the section heights, so now the css is determining the video height.
So at the bottom of your style sheet, try this.
div#bgVideo.skrollable.skrollable-between video#video_background {
min-height:940px !important;
}
#media (max-width: 480px) {
.hero-logo img {
max-width:55%; /*looks nice at 480 */
padding:20px;
}
div#bgVideo.skrollable.skrollable-between video#video_background {
min-height:320px !important;
}
}
#media (max-width: 320px) {
div#bgVideo.skrollable.skrollable-between video#video_background {
min-height:480px !important;
}
}
But Richard, to be honest, you should be troubleshooting and testing the design yourself. How will you ever learn if you don't try. Remember, firebug is your best friend :)

Fullscreen background image buggy in Chrome

I am trying to apply a full screen background image on one of my projects. It works fairly well in IE9 and Firefox but I´ve been struggling with an issue on Chrome because it adds some 1px border to the top and left.
Screenshot: here
I tried to apply border:0; but still nothing.
<img src="./images/highway.jpg" class="background-image" alt="background-image" />
img.background-image {
/* Set rules to fill background */
min-height: 100%;
min-width: 960px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
}
#media screen and (max-width: 1024px) { /* Specific to this particular image */
img.background-image {
left: 50%;
margin-left: -512px; /* 50% */
}
}
Anyone has an idea of what might be causing this? Would appreciate :)
I have the same problem, it is a bug of Chrome, they know that bug, but I think Google won't repair this bug, more than 10 versions since the bug appeared and they still didn't repaired...
If you change the size of the window magically the 1px dissapear (and reapear, depending of somethig inside Chrome)...
Try to put background-attachment: fixed, sometimes it resolves this bug (but your background loses the scroll movement).