Three divs, three links. How to put the links perfect in the center of each div? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Three divs, three links. How to put the links perfect in the center of each div?

Hi guys, I just wrote this code down (see comments). Can you check this? Is this a good way or a bad way? And How do I get my links perfectly in the mid of each div container? Cheers, Robert https://code.sololearn.com/WlLUWu5GpB61/?ref=app

6th Aug 2017, 12:26 PM
SergeantChad
12 Answers
8th Aug 2017, 8:53 PM
Msaligs
Msaligs - avatar
+ 8
Just to make one of the multiple ways to do that. :) https://code.sololearn.com/W8Ajv2TVLs9D/?ref=app
6th Aug 2017, 1:19 PM
Maz
Maz - avatar
6th Aug 2017, 12:34 PM
Maz
Maz - avatar
+ 7
Fixed, now you can click the link only inside the black border (that you can also remove), anyway that's not the best way to center elements, you can re-write the code without use the position property.
6th Aug 2017, 1:05 PM
Maz
Maz - avatar
+ 7
I think that css flexbox model would be better suited for making your layout... Check the rewrote Css rules in this code (removed definition disabled but kept commented): https://code.sololearn.com/W7MxvGCcAT2k/#css
7th Aug 2017, 10:59 AM
visph
visph - avatar
+ 3
Hi Maz, this works perfect, Thank you! But it has one negative side aspect. The box of e.g. "google" is clickable from the left side till the right side. Is there an other way to solve this?
6th Aug 2017, 12:52 PM
SergeantChad
+ 2
Maybe this is a better explanation. The box of every a element is 10px high and now >1000px width. And everywhere where the pixel are, you can click on the box and get a restriction to the link
6th Aug 2017, 12:55 PM
SergeantChad
+ 2
Nice! I would rewrite the code. I only need to change the css, right? What I use instead of position?
6th Aug 2017, 1:11 PM
SergeantChad
+ 2
I'll will check it out in 30 minutes and give u a reply :)
6th Aug 2017, 1:51 PM
SergeantChad
+ 2
Well done mate, its working perfect. Thank you very much! :)
6th Aug 2017, 2:43 PM
SergeantChad
+ 1
just use text-align: center; in the CSS. do they not teach you this stuff?
7th Aug 2017, 8:21 PM
Happy Panda Skulls
Happy Panda Skulls - avatar
+ 1
My thoughts exactly @Happy Panda Skulls Although, by looking at SergeantChad's profile he hasn't had much experience with using CSS, for someone with his experience he did very well, kudos to you @SergeantChad Well done.
9th Aug 2017, 3:23 PM
Christopher Carillo
Christopher Carillo - avatar