why wont my link center?

I made the navbar centered, and i copied and modified the code to fit more with the button type and now it is stuck to the side.🔥
32 Replies
Gray
GrayOP2y ago
thats what the webpage looks like
nickymicky
nickymicky2y ago
use
display: block;
display: block;
instead of display: inline-block; in .clickText class also, I don't think you'd need another display property in .grow class as the display property was already defined in the .clickText class
Gray
GrayOP2y ago
yeah i removed the clicktext class it didnt do anything
nickymicky
nickymicky2y ago
if you removed that class, then the display property in the .grow class should have the value of block
Gray
GrayOP2y ago
ok hang on
nickymicky
nickymicky2y ago
also, justify-content doesn't work unless the display is set as flex or grid. I think, vertical-align property is not needed too, as it doesn't really align it vertically
Gray
GrayOP2y ago
that worked, but now i have an issue. when i remove the grow class from the link, it has a normal button, but if i add the grow class, it makes it stretch farrrrrr
Gray
GrayOP2y ago
made the transform scale 0.5 and this is what i see
Gray
GrayOP2y ago
@nickymicky
nickymicky
nickymicky2y ago
can you please share a codepen link for the code? I'd like to try it myself and see what's causing the issue
Gray
GrayOP2y ago
sure
Gray
GrayOP2y ago
will it accept 2 html
nickymicky
nickymicky2y ago
just put the necessary code in one html file
nickymicky
nickymicky2y ago
okay, let me check and I'll come back once I figure out the issue
Gray
GrayOP2y ago
alright. im going to add some spacing between the join button and the bottom of the vp soon
nickymicky
nickymicky2y ago
alright I think, I'm getting close the root cause of the issue, but before that I have one suggestion, which is, please try to never use vh or vw units for sizing or anything else, they're not good for those things, instead, use rem. vh and vw units cause unexpected behaviour since there are devices with various widths and heights
nickymicky
nickymicky2y ago
For example, take a look at this, the buttons are so small even though the width of the screen is 1920px
nickymicky
nickymicky2y ago
and look at the padding of the buttons, which depend on vw
nickymicky
nickymicky2y ago
Finally, figured it out the solution with a little bit of searching😁
nickymicky
nickymicky2y ago
we just need to put text-align:center; to the parent element, instead of setting it to each child element. Also, like I said before, please stop using vh and vw units, because just for this small problem, I had to struggle a lot to debug the problem as the layout changes caused drastic changes in sizes of the elements, which was very hard to read or click but vh or vw could be great for responsive font-sizes, when used with clamp()
Gray
GrayOP2y ago
so what do i change to get to the button being in the center? so how would i get it to scale for mobile?
nickymicky
nickymicky2y ago
just create a class for the parent element and put text-align:center; in that and remove everything which is commented in the above pic I've sent you
Gray
GrayOP2y ago
just create a class for the parent element and put text-align:center; in that
how?
nickymicky
nickymicky2y ago
i'd say, start with mobile-first design and then gradually change things as device sizes change. You don't need to change for every device, but use common device-size ranges, which are available all over the internet. create a class (e.g. hero, main, wrapper, etc) for the parent div which contains the h1 and the a elements, and put the text-align property for that class inside the css file
Gray
GrayOP2y ago
like that?
Gray
GrayOP2y ago
AH!
Gray
GrayOP2y ago
It works! thank you!
Gray
GrayOP2y ago
although when it expands, it has the overflow
nickymicky
nickymicky2y ago
yes you're welcome!😁 you have to increase the padding on the left and right, when it enlarges
proudyyyy
proudyyyy2y ago
you could've also tried using margin-left: auto; and margin-right: auto 🙂
nickymicky
nickymicky2y ago
I've already tried that, but it didn't work for me for some reason, that's why I didn't provide that as a solution
Want results from more Discord servers?
Add your server