User:Lakelimbo/Sandbox

From Bulbapedia, the community-driven Pokémon encyclopedia.
Jump to navigationJump to search

Image whitespace issue

Bulbapedia has a lot of images with a ton of whitespace, which is used to keep an uniform size between them. However I'm going to show that this is not necessary and not a good web practice, as images should not dictate layout.

Firstly, the images without whitespace are displayed here using MediaWiki's $wgAllowExternalImages, which allows me to display an external image (aka not on Bulbagarden) by just placing the link. So the resizes on the direct images are just how the images would look like if they were trimmed.

Ok let's just compare the amount of whitespace around the icons. The gray background is the actual whitespace of the image.

Menu SV 0444.png
image.png

Now let's see that on a smaller scale, let's say the images can only have 80px:

Menu SV 0444.png
image.png

And now with just 20px:

Menu SV 0444.png
image.png

Considering that almost all images automatically resize on smaller screens, having tons of whitespace will badly affect the UX on mobile and any container that has a limited free space (such as the navigation bar on Pokémon Species pages). Let's use a table to mimic the PokéPrevNext templates, both with a fixed height of 46px (more or less the height of the row of the actual template).

With whitespace:

321MSBDSP.png Wailord Pokémon Diancie Menu SV 0719.png

Without whitespace:

image.png Wailord Pokémon Diancie image.png

In this case we could simply specify the height rather than width, like this: [[File:image.png|x40px]]. And as you can see, the example without the whitespace looks much clearer, despite Wailord being much more horizontal while Diancie being more vertical.

Pokémon Infobox

Using only grid elements! I will continue working on this later.

Jirachi
Wish Pokémon
ジラーチ
Jirachi
#385

385Jirachi.png
Images on the Bulbagarden Archives

Types
SteelIC SM.png PsychicIC SM.png
Ability
Serene Grace
Gender ratio
Gender unknown
Catch rate
3 (1.6%)
Breeding
Egg group
Undiscovered
Hatch time
30840 - 31096 steps
Egg not obtainable
Base experience yield
215
Gen III-IV
270
Gen V+
Leveling rate
Slow
EV yield
Total: 3
3
HP
0
ATK
0
DEF
0
SpA
0
SpD
0
SPE
More details
Shape
Body12.png
Footprint
F385.png
Pokédex color
Yellow
Base friendship
100

External links
  • Link
  • Link
  • Link

typebattle

Now it fills the horizontal blank area around it and it's more-or-less responsive. It uses a bit of a complex grid-template-columns style. The only annoying thing is that I couldn't figure it out how to stretch the height when one of the group of panels ("Offensive" and "Defensive") is taller than the other on some medium-sized screens (where the responsive trigger from grid does not respond).

Offensive

NormalIC SM.png IceIC SM.png DarkIC SM.png RockIC SM.png SteelIC SM.png

½×

PoisonIC SM.png FlyingIC SM.png BugIC SM.png PsychicIC SM.png

GhostIC SM.png

Defensive
½×

BugIC SM.png DarkIC SM.png RockIC SM.png

FlyingIC SM.png PsychicIC SM.png

None

Sprite grid

Making this responsive was not the issue, but rather keeping everything aligned. Due to the variable sizes of the sprites, I thought keeping this as flex would work better, but I may redo this again using grid instead.

Generation I
Red
Blue
Spr 1b 127.png
Front
Spr b g1 127.png
Back
Yellow
Spr 1y 127.png
Front
Spr b g1 127.png
Back
Red
Green
Spr 1g 127.png
Front
Spr b g1 127.png
Back
Generation II
Gold
Spr 2g 127.png
Spr 2g 127 s.png
Front
Spr b 2g 127.png
Spr b 2g 127 s.png
Back
Silver
Spr 2s 127.png
Spr 2s 127 s.png
Front
Spr b 2s 127.png
Spr b 2s 127 s.png
Back
Crystal
Spr 2c 127.png
Spr 2c 127 s.png
Front
Spr b 2c 127.png
Spr b 2c 127 s.png
Back
Generation III
Ruby
Sapphire
Spr 3r 127.png
Spr 3r 127 s.png
Front
Spr b 3r 127.png
Spr b 3r 127.png
Back
Emerald
Spr 3e 127.png
Spr 3e 127 s.png
Front
Spr b 3e 127.png
Spr b 3e 127 s.png
Back
FireRed
LeafGreen
Spr 3f 127.png
Spr 3f 127 s.png
Front
Spr b 3f 127.png
Spr b 3f 127 s.png
Back
Generation IV
Diamond
Pearl
Spr 4d 127.png
Spr 4d 127 s.png
Front
Spr b 4d 127.png
Spr b 4d 127.png
Back
Platinum
Spr 4d 127.png
Spr 4d 127 s.png
Front
Spr b 4d 127.png
Spr b 4d 127 s.png
Back
HeartGold
SoulSilver
Spr 4h 127.png
Spr 4h 127 s.png
Front
Spr b 4h 127.png
Spr b 4h 127 s.png
Back
Generation V
Black
White
Spr 5b 127.png
Spr 5b 127 s.png
Front
Spr b 5b 127.png
Spr b 5b 127.png
Back
Black 2
White 2
Spr 5b 127.png
Spr 5b 127 s.png
Front
Spr b 5b 127.png
Spr b 5b 127.png
Back
Generation VI
X
Y
Spr 6x 127.png
Spr 6x 127M.png
Spr 6x 127 s.png
Spr 6x 127M s.png
Front
Spr b 6x 127.png
Spr b 6x 127.png
Spr b 6x 127M s.png
Spr b 6x 127M s.png
Back
Omega Ruby
Alpha Sapphire
Spr 6x 127.png
Spr 6x 127M.png
Spr 6x 127 s.png
Spr 6x 127M s.png
Front
Spr b 6x 127.png
Spr b 6x 127.png
Spr b 6x 127M s.png
Spr b 6x 127M s.png
Back
Generation VII
Sun
Moon
Spr 7s 127.png
Spr 7s 127M.png
Spr 7s 127 s.png
Spr 7s 127M s.png
Front
Spr b 7s 127.png
Spr b 7s 127.png
Spr b 7s 127M s.png
Spr b 7s 127M s.png
Back
Ultra Sun
Ultra Moon
Spr 7s 127.png
Spr 7s 127M.png
Spr 7s 127 s.png
Spr 7s 127M s.png
Front
Spr b 7s 127.png
Spr b 7s 127.png
Spr b 7s 127M s.png
Spr b 7s 127M s.png
Back
Let's Go, Pikachu!
Let's Go, Eevee!
Spr 7p 127.png
Spr 7p 127M.png
Spr 7p 127 s.png
Spr 7p 127M s.png
Generation VIII
HOME
HOME127.png
HOME127M.png
HOME127 s.png
HOME127M s.png

Side-by-side elements

Pseudo-legendary Pokémon


"Tutorial"

Instead of a table inside a table, take each Pokémon panel and wrap around a div, then wrap all the div with another div. In the "master" div, insert the following CSS:

{
   display: grid;
   grid-template-columns: repeat(auto-fit, minmax(250px, auto));
   gap: .5rem;
   place-content: center
}

Also, remove the margin: auto from the Pokémon tables, place-content: center takes care of that automatically. IMO, it's also preferable to give each table width: 100%.

Red Gyarados

Using this page as an example with the same previous method.

Spr 2c 130 s.png
Types:
Water Flying
Held item:
None
Gyarados Lv.30ShinyIIStars.png
Thrash
Normal
Bite
Dark
Dragon Rage
Dragon
Leer
Normal
Spr 4h 130 m s.png
Types:
Water Flying
Ability:
Intimidate
Held item:
None
Gyarados/ Lv.30ShinyIVStar.png
Bite
Dark Physical
Dragon Rage
Dragon Special
Leer
Normal Status
Twister
Dragon Special

Multiple panels

This one uses multiple tables because Template:ActivePoké and Template:InactivePoké are just cells for tables. Now, instead of a table with multiple cells, each panel (ActivePoké or InactivePoké) has its own table with a single cell. Using Wild Area as an example:

Caught Pokémon:


Code

<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, auto));">
{|
|{{ActivePoké|Wild Area|Braviary|Wild Area Braviary.png|Normal|Flying|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Maractus|Wild Area Maractus.png|Grass|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Wooloo|Wild Area Wooloo.png|Normal|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Ribombee|Wooloo anime.png|Bug|Fairy|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Grubbin|Wild Area Grubbin.png|Bug|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Phantump|Wild Area Phantump.png|Ghost|Grass|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Seedot|Wild Area Seedot.png|Grass|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Goomy|Wild Area Goomy.png|Dragon|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Hippopotas|Wild Area Hippopotas.png|Ground|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Tympole|Wild Area Tympole.png|Water|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Frillish|Wild Area Frillish.png|Water|Ghost|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Flygon|Wild Area Flygon.png|Ground|Dragon|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Snorlax|Wild Area Snorlax.png|Normal|nick=Snorlax ↔ Gigantamax Snorlax|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Rookidee|Wild Area Rookidee.png|Flying|nick=Rookidee|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Budew|Wild Area Budew.png|Grass|Poison|nick=Budew|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Butterfree|Wild Area Maractus Butterfree.png|Bug|Flying|nick=Butterfree|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Joltik|Wild Area Joltik Ditto.png|Bug|Electric|nick=Joltik|link=no}}
|}
{|
|{{ActivePoké|Wild Area|Ditto|Wild Area Joltik Ditto.png|Normal|nick=Ditto|link=no}}
|}
</div>

Caught Pokémon:
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, auto));">
{|
|{{InactivePoké|Goh|Scorbunny|Goh Scorbunny.png|fire|link=Goh's Cinderace}}
|}
{|
|{{InactivePoké|Goh|Boldore|Goh Boldore.png|Rock|link=List of Goh's Pokémon#Boldore}}
|}
{|
|{{InactivePoké|Ash|Dracovish|Ash Dracovish.png|Water|Dragon}}
|}
{|
|{{InactivePoké|Goh|Arctozolt|Goh Arctozolt.png|Electric|Ice|link=List of Goh's Pokémon#Arctozolt}}
|}

Headers/sections

It's also possible to make multiple sections side-by-side. Section 5 span 2 columns.

This is very useful for a lot of elements, but for sections (unless it's only 2 sections), it will need a media query.

Section 1

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Section 2

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Section 3

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Section 4

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Section 5

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Code

<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(33%, auto))">
<div>
==== Section 1 ====
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
<div>
==== Section 2 ====
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
<div>
==== Section 3 ====
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
<div>
==== Section 4 ====
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
<div style="grid-column: span 2">
==== Section 5 ====
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
</div>

Pokéathlon stats

2/5
★★☆☆☆
5/5
★★★★★
2/3
★★☆
3/4
★★★☆
5/5
★★★★★
17/22
★★★☆

Gallery alternative

Pretty straightforward. The outer container uses a max-width of 1279px, but depending on the size of the images you set you should adapt this to avoid having very large gaps.

If you like more a dynamic positioning though, you could also switch the max-width to justify-content and choose between space-around (will spread the items around, relative to the container's width), space-between (similar to the previous one but will try to force the elements to start at the very beggining of the container) or space-evenly (will try to calculate a distance width depending on the width of the element, so if all elements have a equal width it will behave just like space-around).

PCGIGP Charizard1.jpg
Caption here
PCGIGP Charizard2.jpg
Caption here
PCGIGP Charizard3.jpg
Caption here
PCGIGP Charizard4.jpg
Caption here
PCGIGP Charizard5.jpg
Caption here
PCGIGP Charizard6.jpg
Caption here
PCGIGP Pikachu1.jpg
Caption here
PCGIGP Pikachu3.jpg
Caption here
PCGIGP Pikachu4.jpg
Caption here
PCGIGP Slowpoke1.jpg
Caption here
PCGIGP Slowpoke2.jpg
Caption here
PCGIGP Slowpoke3.jpg
Caption here
PCGIGP Slowpoke4.jpg
Caption here
PCGIGP Slowpoke5.jpg
Caption here
PCGIGP Slowpoke6.jpg
Caption here
PCGIGP Slowpoke7.jpg
Caption here
PCGIGP Slowpoke8.jpg
Caption here
PCGIGP Slowpoke9.jpg
Caption here
PCGIGP Slowpoke10.jpg
Caption here

NIWA template

Very similar to the original, but of course using flexbox. I also removed the icons as they were pretty much pointless. Text color contrast has also been fixed.

Anmov

Ash Caterpie String Shot.png
Using String Shot as a Caterpie
Ash Butterfree Sleep Powder.png
Using Sleep Powder
Move First used in
String Shot Ash Catches a Pokémon!
Tackle† Ash Catches a Pokémon!
Harden Ash Catches a Pokémon!
Sleep Powder† Ash Catches a Pokémon!
Whirlwind† Ash Catches a Pokémon!
Stun Spore† Ash Catches a Pokémon!
A † shows that the move was used recently, unless all moves fit this case or there are fewer than five known moves.