Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css width fit content cancels text align center

Tags:

html

css

I try to center a pragraph and give it a background with low opacity to make it easier to read over the main background. I use

background-color: rgba(255, 255, 255, 0.2);
background-blend-mode: lighten

but when I add

width: fit-content;

it pushes the text to the right side of the screen and ignores the text align.

background-color: rgba(255, 255, 255, 0.2);
background-blend-mode: lighten;
width: fit-content;
like image 322
ofek hamdi Avatar asked Oct 19 '25 09:10

ofek hamdi


1 Answers

use

width: fit-content;
margin: auto;

to do both and center text

like image 75
CoderTang Avatar answered Oct 21 '25 23:10

CoderTang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!