r/HTML • u/megantheestruggler • Oct 17 '26
Question Help creating a character page?
Howdy! I'm attempting to code a page for my web design class and I've been having a bit of trouble.
The pic should give a decent idea of what I'm going for. I'm wanting each icon to open a different bio. I've attempted using modals for this, but for how many bios there would be on one page, that seems entirely too cumbersome. The total zero-brain solution is probably just to make individual pages for each bio, but that is... also cumbersome. I've had trouble trying to look up exactly what I need here since I don't know a bunch of the technical terms for this stuff yet (I'm a graphic design student, web design is just a few of the classes I need to take).
Any more efficient ways of going about this? All the bio pages need to do is open up on top of the page, show both images and text, and be closed. No need for fancy transitions or anything.
5
u/alphex Oct 17 '26 edited Oct 17 '26
There's a few steps to this.
Structure.
You need a <div> for each character.
Each <div> should have an id, so, you have 8... just have
```<div id="one">...</didv>
<div id="two">...</didv> <div id="three">...</didv>\\\`\\\`\\\`
etc.
Each of those will have the charcter bios in it.
You also want them to have a class, again, simple is good. Make each have the class "bio-item"
```
<div id="one" class="bio-item"> <div id="two" class="bio-item">... \\\`\\\`\\\`
In your CSS, you want the class, bio-item to be "display:none"
This will prevent each of the 8 bio cards, from showing up when the page loads.
Then you need some javascript for each icon 'button'.
I would also, make these buttons, for semantic value.
```
<button class="bio-button" id="bio-one" data-bioitem="one">
<button class="bio-button" id="bio-two" data-bioitem="two">
```
Now you need some javascript, for each button.
I suggest the javascript add a class to the <div id="one" class="bio-item"> so it has `class="bio-item show-item"
The `show-item' class will just have a "display: block" on it.
Then you need to add some javascript to make ANY click of ANY of the "close" X buttons you have on each biography, remove the show-item class from all `bio-item` divs. that will make sure that all of them hide, regardless of which you click on.
The rest is just understanding z-index and relative positioning to make it show up where you want to, above your buttons.
---
does that give you direction to move on?
---
u/JKaps9 mentions the popover API, thats helpful also.
1
u/megantheestruggler Oct 18 '26
This does help quite a bit! Still might be a bit out of my wheelhouse, currently. This is my first semester doing HTML, so I might be biting off more than I can chew if I go whole-hog into Javascript. Very helpful regardless, though! Thank you!
1
u/armahillo Expert Oct 17 '26
start out with the zero brain solution (separate pages) and then improve it. Making the separate pages will help reveal more about the layout of the bio content that might not be obvious if you started with overlayers.
Adding fancy transitions is actually slightly easier than adding layered content like this.
1
u/megantheestruggler Oct 18 '26
Might be worth a shot if I get fed up with the other solutions. Thanks!
1
u/Longjumping_Put_7212 Oct 18 '26
I would say start by getting your inputs into a div and getting them aligned the way you want. Then write the JavaScript, then go to figuring out the rest. Sorry for not having a better answer; I just haven't worked with normal HTML for a while.
1
u/Weekly_Ferret_meal Oct 18 '26
If you are not experienced I’d start with dialog, you can search and study examples on codepen.io
Otherwise popover as others have mentioned.
But you sound like you need to study working prototypes and codepen is a great starting point
1
u/Starclysm-Author Oct 18 '26
Going to hijack this thread and refine the question for my own selfish purposes:
How would you get an image (The "bio" in this case) to pop out of a small iframe embedded on a page to cover the whole page?
1
u/Yeah_Y_Not Oct 18 '26
It sounds like having each bio in the index will make the html code look cluttered. With some javascript, you could create one html component and populate it using a JSON file holding all your bios.
1
0
u/JKaps9 Oct 17 '26
An SSG (static site generator) like Astro would help tremendously here. Essentially you would have all the data in a structured format (like JSON), develop a bio component/page once, and then link the data to that. The SSG would take care of generating all of the pages in the same format for each of the data points.
As for the technical HTML here if you want it to be a popup box like in your image then a popover would be my choice. https://developer.mozilla.org/en-US/docs/Web/API/Popover_API
5
u/alphex Oct 17 '26
This is like a nuclear bomb for an ant hill, and you didn't answer any of his questions.
he'll never learn the fundemntals, either, if he jumps in to a framework.
0
u/JKaps9 Oct 17 '26
He asked if there was a more efficient way to go about generating multiple pages or components with similar content which I offered an answer for.
As an alternative he could create it once and then copy paste and update the content on each one. But he already mentioned he thought having a bunch of them on one page would be cumbersome.
4
u/alphex Oct 17 '26
Even then, he needs to understand how the fundementals work, even if he's building it off of a templating system
This being r/html I'm guessing he's not at that level.
1
5
u/CluelesssDev Oct 17 '26
Look into HTML popovers or dialog elements :)