Okay I've been banging my head against this one for a few hours, so now it's time to throw it on here and see if anyone can help:
The basic problem is that I've got an SVG on an html page, that's styled to be responsive, and adjust to the width of the browser window. The code works perfectly fine in both IE and Chrome, but on Firefox when the window gets smaller than a certain size, the SVG stops scaling. It will scale up fine. Just to infuriate me, it also appears that when I 'inspect element' in Firefox, and check out the code, the SVG resizes properly to fit into the now smaller viewing area. Here's some screenshots of what I mean:
Here's my code, as basic as it is:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Glynne McReynolds</title>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<header>
<img src="images/glynne-mcreynolds.svg" alt="Glynne McReynolds" title="Glynne McReynolds">
</header>
</body>
</html>
And the relevant CSS:
header {
max-width: 500px;
text-align: center;
margin: 0px auto;
}
header img {
width: 100%;
height: auto%;
}
I should note that I've also included the development build of modernizr.js, but removing it doesn't make any difference, so I left it out.
Things I've tried:
Removing the width and height declarations from SVG.
Embedding the SVG as an object instead of in an img tag.
Also here's a fiddle with the code, and here's the SVG. Any help would be much appreciated.
Your Firefox screenshot shows that the window is narrower than the browser UI will go (note the cut-off toolbar), so that the viewport is actually ending up wider than the window.
As Robert mentions above, the inability of the UI to shrink past a certain point is often caused by add-ons that add non-flexible elements to the UI....
Related
body {
margin: 0;
}
div {
box-sizing: border-box;
background-color: red;
width: 100%;
height: 300px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div>Text that overflooooooooooooooooooooooooooooooooooooooooooooooooooooooooooows </div>
</body>
</html>
When I inspect the above page with Chrome devtools, turn on Device Toolbar
and set device width to anything below 450 (so that the text overflows)
and device type to Mobile,
there is a gap of space to the right from div.
And as I adjust the width of the device the width of the div is always smaller than the width of the screen. Though the text overflows I expect the div to always be as wide as the screen because the div is a child of the body and it has width: 100%;. Moreover, the devtools say that the div has the same width as the screen.
This issue does not happen on desktop (i.e. if I set device type to Desktop).
What is even weirder is that the devtools say that the div is as wide as the screen.
If I switch to Desktop device type and then back to Mobile than the issue disappears but the page seems zoomed in.
Also when I launch this page on a real mobile device where text still overflows, the issue seems to disappear
but when I zoom out it is still there.
So I assume that when I initially opened the page on the real mobile device, the browser set the zoom value automatically so that the div seems to be as wide as the parent.
What piece of HTML and CSS theory do I miss so that I don't understand the reason behind the issue? Why does it happen? How do I fix the problem?
Try this instead:
div {
box-sizing: border-box;
background-color: red;
width: 100vmax;
height: 300px;
}
I think the problem is the word 'overflooooooooooooooooooooooooooooooooooooooooooooooooooooooooooows' is so long and exceeding the div.
Now, I'm not sure why it's just happen on desktop using mobile mode.
But you can fix it using in your CSS div class the following line
word-break: break-all;
This will force the word break.
Result
Result after add "word-break: break-all;"
You have this pen here.
https://codepen.io/iwaduarte/pen/mdJvaLj
The thing is you can NOT reproduce the error unless you copy it and test locally in your own browser.
Every time that I alter the type of view (from desktop to mobile) the footer section gets pushed down. It adds an unnecessary: height?
So if you hit the Toggle device toolbar (Chrome) in the Inspection tools you will see that the <footer> gets pushed down.
Why is that happening? I know it is overflowing the X-axis but why is adding a scrollbar while in "mobile mode"?
Is that a bug? How to solve that?
Is that a bug? How to solve that?
It seems to me that the absence of the viewport meta info causes this problem. Since the CSS fixed property makes an element to get positioned relative to the view port, by default the standard mobile device height is taken as reference viewport (e.g. Pixel 2 has 411x731px).---
In order to prevent something like this from happening you should provide the viewport meta info in the head, a la:
<meta name="viewport" content="width=device-width, initial-scale=1.0">
#comment: It is not causing the problem. My local index.html has this
tag.
I think, I found the cause. Looks like you have to set overflow to auto (default is visible) for the html and body. It should work. I just tested on my mobile phone (should have done it before posting my answer first).
Checkout this example, and give me feedback whether and how this works for you:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<style>
.bot-footer {
background-color: #59e01b;;
color: white;
position: fixed;
left: 0;
bottom: 0;
font-size: 3vw
}
html, body {
overflow: auto;
}
</style>
</head>
<body>
<div id="root">
<hr style=" width: 3000px;"/>
<footer class="bot-footer">Like at least </footer>
</div>
</body>
</html>
In this simplified HTML, I have a fixed div that is meant to be the exact width of the window. But there is also a very long word in the content above the div that messes up the layout.
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1">
<style>
div {
position: fixed;
left: 0;
right: 0;
display: flex;
justify-content: space-between;
}
</style>
</head>
<body><p>Veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongword</p>
<div><b>0%</b><b>25%</b><b>50%</b><b>75%</b><b>100%</b></div>
</body>
</html>
It looks as if the long word causes the "viewport" to stretch to be wider than the window, so the div (fixed to the viewport) ends up being wider than the window.
Now this only happens on mobile devices, even using Chrome Dev Tools. In Desktop mode, all is fine:
But change to Mobile and the fixed div stretches:
So two questions:
How can I prevent the div from stretching wider than the window?
What is Chrome Dev Tools doing differently when I switch to Mobile view?
1) I've managed to fix all the issues I can create with your code by:
p {
max-width: 100vw;
overflow: hidden;
}
2) Chrome does very strange things with the width of that div as I mess with the css and refresh the page. It does not render at all consistently even with the same css. In fact, I have two tabs open that show the page differently from the same code in the same file, even while refreshing. I think the behavior of a div when smaller than the viewport may be unspecified, and you must use something like my solution to tell Chrome what to do.
this problem is caused by justify-content: space-between. You dont actually set a width, and different things add different amounts of spacing.
If you were to set a width for the div like this: width: 300px, the width wouldn't change on mobile or pc.
So i have a ridiculous problem, that ought to be obvious and simple yet I can't seem to find out what the problem is.
I have a div on a page that uses bootstrap.
The code for that div is as follows:-
.appSection{
background-color: #000000;
padding:20px;
border:1px solid #67c1dd;
margin-bottom: 30px;
display: block;
width: 100%;
min-height: 450px;
}
Its a child of a div wrapper col-md-12.
This display fine in most browsers I've used; however, when the div does not contain much content or text at the head of the div, on the iPad the div collapses as shown in the right side of the attached image. Sometimes it can literally be collapsed almost completely to the right of the underlying menu.
Any clues?
You haven't given us enough information to go off. If we could see a sample of you html and css that would be great.
If you are reviewing it on iPad in portrait, then your "col-md-12" class on the parent div is not being applied, as that starts at 992px. That is probably 'part' of your problem. It's not the root cause though. but with nothing else to go on, try changing it to "col-xs-12" and see if that fixes it.
I've found the problem.
I had this meta tag at the top of my page, when I removed it, the problem was resolved:-
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
Is there anyway to get a consistent border around images for Internet Explorer and Microsoft Edge browsers? At different breakpoints (if you zoom in and out), the specific sides the border shows up on varies. Sometimes it shows the border on the top and left sides, sometimes the top and right sides, etc. I would like it to show up on all sides for all breakpoints.
I've tried:
Putting a border around the img tag itself using the CSS border property
Wrapping the image in a div tag with the CSS border property
EDIT: I've tried to update the border to 2px, and the border shows, but at certain breakpoints it grows larger/smaller, in an inconsistent manner + there is a slight padding in the image at certain breakpoints, . I believe something in IE/Edge causes the image borders to vary the border thickness in an inconsistent manner.
The code:
http://jsbin.com/befuqekofa/1/edit?html,output
#image{
border: solid 1px black;
}
#border {
width: 500px;
height: 500px;
border: solid 1px black;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<img id = "image" src="http://placehold.it/500x500">
<div id="border">
<img src="http://placehold.it/500x500">
</div>
</body>
</html>
Any help would be greatly appreciated!
The thing with zooming in and zooming out a web page is that it will always have some weird artifacts, and I'm not sure about your question.
If you're trying to do breakpoints (#media), why would you zoom in and out the page? The scaling that devices might apply ( with higher pixel dpi screens ), they have a better way for drawing/rendering does kind of stuff. So maybe, no, for zooming in and out on IE and Edge. I think that's how it's just rendered. But you'll have that issue even with background-positioning, floats etc... and maybe other browsers.
If you want to have like a better scaling border, so it will change dynamically for zooming and breakpoints, you could use em or rem depending on your structure.
Hope that makes sense,
Cheers!