Answer the question
In order to leave comments, you need to log in
How to fit SVG on screen when changing orientation?
Good afternoon, dear colleagues!
I draw a page that has a static header and footer, and all the space between them should be occupied by a block with SVG inside
<!-- index.php -->
...
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
...
<body>
<div class="header">
...
</div>
<div class="main">
<div class="content">
<svg id="main_svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 132 132">
<use xlink:href="/assets/image/main.svg#common" />
</svg>
</div>
</div>
</div>
<div class="footer">
...
</div>
</body>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body, html{
color: #fff;
background-color: #000015;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.header {
width: 100%;
flex: 0 0 auto;
}
.main {
flex: 1 0 auto;
}
.footer {
flex: 0 0 auto;
width: 100%;
background: #00000a;
}
@media screen and (orientation : portrait){
.content {
width: 100%;
}
}
@media screen and (orientation : landscape){
.content {
height: 100%;
}
}
Answer the question
In order to leave comments, you need to log in
Try jsom to change the Viewbox in its attributes, I'm not sure what will work, but you can try experimenting with this viewbox
Try replacing the viewbox with wight and height and set it to 100%
How to make rubber svg? , and specifically the example https://codepen.io/tolfy/pen/LNpEgP
try to change the orientation, the property workspreserveAspectRatio="none"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question