How do center my links? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do center my links?

I can center "Edward" but "Email" and "instagram" won't. https://code.sololearn.com/W1IVyY5SkvB6/?ref=app

30th Jun 2017, 2:57 PM
Edward
Edward - avatar
9 Answers
+ 1
@Nomeh He is creating a title/nav bar, so that is the only things he needs centered at the moment. He is utilizing classes, whereas that is going to imply that all DIVs on the document should be centered.
30th Jun 2017, 3:10 PM
AgentSmith
+ 14
You could set the margin of your Instagram link so that it gets to the center of your page : .pagelinks { display: flex; margin-left: 100px; // can be modified accordingly. } /* Setting the margin comes in handy most of the times. This is an alternative way of alignment */
30th Jun 2017, 3:04 PM
Dev
Dev - avatar
+ 13
@Edwards : Try this! Maybe this is what you need?? Use flex instead of inline as the display value. .pagelinks { display:flex; margin-left: 100px; }
30th Jun 2017, 3:22 PM
Dev
Dev - avatar
+ 3
.pagelinks{ text-align:center; } https://code.sololearn.com/W1Nls1pDhlTI/#css ^Your code updated.
30th Jun 2017, 3:06 PM
AgentSmith
+ 2
@Edwards Margins are great when you're dealing with a bunch of divs/nested divs, in which case you'll find yourself using 'margin: 0 auto;' a lot to deal with aligning them. (Don't forget the width of your div in that situation if it's nested) Anyways, if you go about this particular problem with margins, you're going to run into alignment issues you don't want, for example 100px is simply shifting it over 100 pixels, which isn't necessarily the center. Resize your browser and you'll see what I mean.
30th Jun 2017, 3:15 PM
AgentSmith
+ 1
insert this code at the end of your css code ______ div { text-align: center; } or better .pagelinks{ text-align: center ; }
30th Jun 2017, 3:06 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 1
How do I get all the text in the middle of the screen as the vertical-align: middle also doesn't seem to work for me. https://code.sololearn.com/W1Nls1pDhlTI/?ref=app
30th Jun 2017, 3:50 PM
Edward
Edward - avatar
0
Thanks guys but now "Email" and "Instagram" are displayed on a different line when I want them on the same. why is this?
30th Jun 2017, 3:08 PM
Edward
Edward - avatar
0
@netkos thanks
30th Jun 2017, 3:44 PM
Edward
Edward - avatar