简体   繁体   中英

How do i make a centered “block of text”

this is HTML and CSS.

这就是我想要的样子:

现在是这样的:

this is my code:

p {
color: white;
text-align: center;
font-family: Helvetica;
} 

with the correct paragraph syntax infront of this text and after this text: its glitching on stackoverflow for me idk y (im talking about the text under this line)

the upper image is how i want it to be and the lower image is how it currently is

you have to assign a width to your paragraph. then add margin: auto;

p {
    color: white;
    text-align: center;
    font-family: Helvetica;
    background-color: black;
    width:35%;
    margin:0 auto;
    padding:15px;
    } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM