Comments (10)
@WDGroll does background-size: 100% 100%;
help here?
Have you got a version of your example in a live code editor (e.g. codepen), or even just on a server somewhere that I can play with?
from content.
No,
background-size: 100% 100%;
doesn't help. Looks it scales to it's parent element, not to the size of the viewport.
I created a tiny example for testing:
from content.
Hrm. I've just played around with this a whole load, and can't get to what you are hoping for.
The closest I can get is
html {
height: 100%;
background-image:url("./rainbow.svg");
background-repeat: no-repeat;
background-size: 100% auto;
}
But that only gives you the effect in the width direction. It fails with a narrow viewport.
It looks like Chrome behaves the same, leading me to think maybe it was a spec change?
from content.
Well, it worked in the past, and I don't know whether there was a specification change since then.
Maybe I misinterpret the specifications.
https://www.w3.org/TR/css-values-3/ ยง 5.1 or
https://www.w3.org/TR/css-values-4/ ยง 6.1.2.
According to this, 100vw and 100vh should be exactly the size of the viewport.
Is there any other way to achieve this only in CSS without using Javascript?
example-3159-v2.zip
from content.
I wonder if @rachelandrew has an idea about a solution for this one?
from content.
According to this, 100vw and 100vh should be exactly the size of the viewport.
I was about to suggest just this.
Is this about applying a user stylesheet (which would apply to all webpages) or only for a specific website (htdocs/index.html makes me think of a locally running Apache web server).
from content.
Seems to work fine with an image, so I'm not sure why not with the SVG.
https://codepen.io/rachelandrew/pen/cb98439b1f485cd33c55a582da973dd4
from content.
Oh. I just had a thought.
You need `preserveAspectRatio="none" on your SVG.
https://codepen.io/rachelandrew/pen/6be905fc1f68875f5d8ac64c5ce06c0a
from content.
@rachelandrew nice, thanks Rachel!
from content.
I was trying to see where this info could be added, and found this: https://developer.mozilla.org/en-US/docs/Web/CSS/Scaling_of_SVG_backgrounds
So maybe I'll add it as a note.
from content.
Related Issues (20)
- [WebAPI] Enable Screen Wake Lock API by default - again HOT 1
- Fragment shader contains wrong code
- Incorrect code example in AbsoluteOrientationSensor docs
- Mention that "customized built-in elements" are not, and will not be, supported on major platforms (Safari iOS/macOS) HOT 2
- Confusing/wrong explanation of the span keyword
- Add sticky column headers for browser compatibility HOT 1
- [WebAPI] Implement URL.parse()
- [CSS] Implement shape() function for clip-path, offset-path HOT 1
- [CSS] Support for the from keyword in relative color syntax
- [MathML] Move the default adjustment for centered operators behind preference
- [WebAPI] Implement IDBFactory.databases() HOT 1
- [WebAPI] Update RTCIceCandidate member attribute and parsing HOT 2
- [HTTP] Import zstd library HOT 1
- [Invalid][WebAPI] Update getAttribute behvior for XUL elements HOT 2
- [WebAPI] Implement context loss for CanvasRenderingContext2D HOT 2
- Algorithm for `:user-valid` seems invalid in itself
- [css] circle() - Typo? HOT 1
- Explanation of `bounded-floor`/`local`/`local-floor` needs improvement
- This content reffers to a header `Report-To` that I don't think exists?
- Rewrite "Synchronous and asynchronous requests" in XMLHttpRequest docs so it makes sense
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from content.