A small CSS & HTML Drawing poject
See it on Codepen
Planning
Found a sample image to mock on google.
Then arranged the basic layout.(using draw.io)
I used a grid for the main structure and most of the sections in the grid as a flex-box.
I also colored parts I thought would share the same properties so I could try to reuse some classes.
Start Coding
I started to write the left panel, everything got pretty good as planned, up to the navigation button.
I couldn't remove the border of the top rectangle in the middle.
So, I google it.
I found a way to make it work by adding borders with the same color as the button background and position them so they cover the original border.
HTML
<div class="nav-button"> <div class="nav-center-circle"></div> <div class="nav-button-vertical"></div> <div class="nav-button-horizontal"> <div class="border-top"></div> <div class="border-bottom"></div> </div> </div>
CSS
.border-top { border-top: 3.5px solid var(--main-buttons-color); position: absolute; top: -3px; left: 20px; right: 19.5px; } .border-bottom { border-top: 3.5px solid var(--main-buttons-color); position: absolute; top: 11px; left: 20px; right: 19.5px; }
Finally it looks like that:
Adding curved lines
At first I tried to use the same method with the borders, but it didn't work as planned (mainly because of the positioning).
I found out about SVG drawing and it turned out to be a good solution.
<svg height="100" width="225" class="left-svg"> <polyline points="0,75 70,75 90,38 224,38" style="fill: none; stroke: black; stroke-width: 3" /> </svg>
For the right panel I used the same technique.
For cutting the right panel border I used pseudo element:
#right-panel { background-color: var(--main-bg-color); box-sizing: border-box; position: relative; height: 100%; width: 50%; display: grid; grid-template-rows: 24% repeat(4, 19%); border-bottom: solid black 3px; border-bottom-right-radius: 10px; } #right-panel::before { content: ''; position: absolute; left: -3px; bottom: 0; width: 100%; height: 265px; border-right: solid black 3px; border-bottom-right-radius: 7px; }
Adding some Javascript
The only thing left is to fetch some data and display it on the screens.
For this I used the pokeapi and some JS
const getPokemonData = (pokemon) => { fetch(`https://pokeapi.co/api/v2/pokemon/${pokemon}`) .then((response) => response.json()) .then((data) => { let id = ('00' + data.id).slice(-3); imageScreen.style.backgroundImage = `url('https://assets.pokemon.com/assets/cms2/img/pokedex/full/${id}.png')`; nameScreen.innerHTML = data.name; typeScreen.innerHTML = data.types[0].type.name; idScreen.innerHTML = `#${data.id}`; aboutScreen.innerHTML = `Height: ${data.height * 10}cm Weight: ${ data.weight / 10 }kg`; inputField.value = ''; }); };
The full Code is on Codepen
Thanks for reading and I hope you liked it.
Top comments (7)
I appreciate you doing this because it's awesome and I was trying to figure out how to make a pokedex that actually looked like dex rather than just the regular pages with a list of sprites.
Great topic. Thanks for fantastic info I was looking for this information for my project! Dragon tiger online
Hi Oryam! Thanks for this tutorial. Just wanted to let you know that I used your codepen as an example to build my own pokedex functionality. I credited your work in the readme: github.com/robiningelbrecht/vanill.... Hope you don't mind?
Wow thanks 😊
Glad to hear you found it useful
its great post you have shared . world777 com id
Can you do anything with CSS?
Love spells in dubai
Wow, creating a Pokedex with CSS is a fascinating journey that allowed me to blend creativity and technical skills seamlessly!
Fairbet 7 com login registration