I am trying to develop a website using Gatsby and React (however, this question is about React).
I am new to web development so I am trying to figure out some of the basics.
My issue is with the landing page. I made two SVG's I would like to be a part of the landing page (Text and a Logo) but I can't size them correctly while also making them responsive.
Image of what I want the page to look like
The reason I am using SVG's is because I wrote a little JS piece that animates the hero when you open the page.
I read lots of Stack Overflow questions on making SVGs responsive using the viewBox attribute but I can't figure out how to set the size of the two SVGs without removing its responsive qualities. So, the page just has two huge SVGs spanning the whole viewport.
An issue I noticed is that if I embed the two SVGs in a div, if I go to inspect that div then it has a height of 0 and is in the top left corner and the SVGs are way out in the middle of the page, as they do.
I am using Bootstrap 4 and have a little Navbar at the top that everything seems to be ignoring (as in, my div seems to go behind the Navbar all willy-nilly).
The following is the code structure I am using to render this (through React components):
<div>
<Hero>
<HeroTitle>
<svg1>
<svg2>
<HeroTitle/>
</Hero>
</div>
CSS for SVGs:
#svg-hero-container {
display: inline-block;
position: relative;
height: 200px;
width: 100%;
padding-bottom: 100%;
vertical-align: middle;
overflow: hidden;
}
#svg1 {
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%,-50%);
}
#svg2 {
position: absolute;
top: 60%;
left: 50%;
transform: translate(-50%,-50%);
}
<svg id="svg1" viewBox="0 0 742 58" preserveAspectRatio="xMinYMin meet" fill="none" xmlns="http://www.w3.org/2000/svg">
...
</svg>
<svg id="svg2" viewBox="0 0 672 210" preserveAspectRatio="xMinYMin meet" fill="none" xmlns="http://www.w3.org/2000/svg">
...
</svg>
Any advice would be appreciated.
Here is a live site of where I'm at: https://emmarose.netlify.com/
Here is the GitHub repo in case my code isn't sufficient: https://github.com/eduardoRubioG/emrose-cslate
Aucun commentaire:
Enregistrer un commentaire