Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm working on my personal website, just learning. I have a large, main block of text with my site name, and under it some links to my social media, etc. The problem is the large, main block of text scales perfectly, but the small text under it does not.

The code I currently use for placing it is here:

HTML
<!--text-->
<div class="center">
<p style="position: absolute; top: 32%; left: 50%;  transform:
translate(-50%, -50%); font-family: 'Qwigley'; font-style: normal; font-
size: 72px; color: white; text-shadow:0px 0px 5px white;">ndb.life</p>
<a style="position: absolute; top: 44%; left: 44.5%;  transform:
translate(-50%, -50%); font-family: 'Courier New'; font-size: 14px; font-
style: normal; color: white; text-shadow: 0px 0px 1px white; text-
decoration: none;" href="http://steamcommunity.com/id/xfh" rel="noopener
noreferrer" target="_blank">(main) steam</a>
<a style="position: absolute; top: 44%; left: 50%;  transform:
translate(-50%, -50%); font-family: 'Courier New'; font-size: 14px; font-
style: normal; color: white; text-shadow:0px 0px 1px white;">youtube</a>
<a style="position: absolute; top: 44%; left: 54%;  transform:
translate(-50%, -50%); font-family: 'Courier New'; font-size: 14px; font-
style: normal; color: white; text-shadow:0px 0px 1px white;">configs</a>
<a style="position: absolute; top: 44%; left: 57.5%;  transform:
translate(-50%, -50%); font-family: 'Courier New'; font-size: 14px; font-
style: normal; color: white; text-shadow:0px 0px 1px white;">email</a>
</div>


The class used on the div is in my style.css here:

CSS
#center {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}


Try it out yourself, just mess with the window size and watch as the text goes inside each other and move weirdly. Any way to fix this?

Demo[^]

What I have tried:

Changing the position of the div and the text from absolute to relative to fixed etc. nothing seems to work.
Posted
Updated 9-Jan-18 6:08am
v2
Comments
Richard Deeming 9-Jan-18 10:43am    
The link to your site was broken. I've changed it to link to a JSFiddle with just the relevant parts, so that it doesn't look like you're just trying to get more visitors to your site.
Richard Deeming 9-Jan-18 10:47am    
You're using absolute positioning and transforms to position your text. That's only going to work if you view it at the exact size it was designed at. As soon as you resize the window, you're going to get the strange effects you're seeing.

There are much better ways to position the content. Can you give us a rough idea of how you want it to be laid out?

1 solution

the class is statr with .(dot) .But you use # .So Instated of #center {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}

.center {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900