What's the best practice for centering all text in the Apple, Banana and Carrot divs?

前端 未结 2 659
梦谈多话
梦谈多话 2021-01-25 10:07

I\'m trying to keep the same styles (summary-description and summary-headline). I would want the divs that include Apple, Banana and Carrot text to all be centered.

I wo

2条回答
  •  伪装坚强ぢ
    2021-01-25 10:38

    In order to have the all the p selectors centered except the one containing watermelon information, which you want left aligned, you have to have a special identifier for the watermelon paragraphs.

    Add
    id="watermelon"
    to

    Watermelon

    and

    .

    Then change the CSS to

    p:not(#watermelon) { text-align:center; }

    This will select all p that do not have the id of watermelon and center the text. Since you have .summary-headline and .summary-description as text-align:left, the watermelon will remain left-aligned, while everything else will become centered.

提交回复
热议问题