Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
a Summer night - @973.88 (what is this?)
Activity rating: Three Stars Posts & Arts: 29/1k.beats Random | Recent Posts | Guild Recents
News: :skull: Websites are like whispers in the night  :skull: Guild Events: Happy Pride Month Fibre Artists!

+  MelonLand Forum
|-+  Life & The Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  HELP: Text does not want to be centered properly


« previous next »
Pages: [1] Print Embed
Author Topic: HELP: Text does not want to be centered properly  (Read 1259 times)
BlazingCobaltX
Hero Member ⚓︎
*****
View Profile WWW


⛺︎ My Room
StatusCafe: blazingcobaltx
RSS: RSS

Guild Memberships:
Artifacts:
First 1000 Members!Joined 2023!
« on: an Autumn day » Embed

For my site I am using a premade template that has some odd quirks. One in particular is that, when using <center>, text doesn't fully center according to the box but according to the span of the text. Example page here.

Relevant (I think) CSS:
Code
.container{
display: flex;
flex-direction: column;
margin-left: 200px;
}
 
.boxgap{
display: flex;
flex-direction: column;
gap: 1rem;
}
 
.box{
display: flex;
flex-direction: row;
background-color: #fffefc;
border: 3px solid #967e68;
}

.left{
border-right: 3px solid #967e68;
padding: 0.7rem;
text-align: center;
}

.right{
padding: 1rem;
}

I've tried editing the display from flex to something else but the CSS seems highly unresponsive (same issue with changing font sizes). The only fix I've found is to make an entirely different div. This one somehow allows itself to be centered. What is happening?

Code
.scrollbox{
display: block;
flex-direction: row;
background-color: #fffefc;
border: 3px solid #967e68;
height: 500px;
overflow: auto;
}

Many thanks in advance.
Logged

https://blazingcobaltx.neocities.org/images/arceus.png
TheNothingMonster
Sr. Member ⚓︎
****
View Profile WWW


Hey psst! Wanna see something spooky?
⛺︎ My Room
StatusCafe: thenothingmonster

Artifacts:
Great Posts PacmanFirst 1000 Members!Joined 2023!
« Reply #1 on: an Autumn day » Embed

<center> will act a bit strangely when working with flex properties. It's a kind of tag that is not really needed (nor suggested) when working with certain CSS stylings.

Whenever you want to center a div, I suggest you adding margin-right: auto; & margin-left: auto; to its properties.

Since the content you want to center are inside the ".right" div, you can just add these properties to it. That should do it! :ha:

Code
.right{
  padding: 1rem;
  margin-right: auto;
  margin-left: auto;
}

If something is not working for you, let me know!
Logged

~~~~~~~~~~~~
BlazingCobaltX
Hero Member ⚓︎
*****
View Profile WWW


⛺︎ My Room
StatusCafe: blazingcobaltx
RSS: RSS

Guild Memberships:
Artifacts:
First 1000 Members!Joined 2023!
« Reply #2 on: an Autumn day » Embed

<center> will act a bit strangely when working with flex properties. It's a kind of tag that is not really needed (nor suggested) when working with certain CSS stylings.

Whenever you want to center a div, I suggest you adding margin-right: auto; & margin-left: auto; to its properties.

Since the content you want to center are inside the ".right" div, you can just add these properties to it. That should do it! :ha:

It worked!! Learned something again, thank you very much :4u: 
Logged

https://blazingcobaltx.neocities.org/images/arceus.png
Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
MelonLand @000

Minecraft: Online
Join: craft.melonking.net