Indent starting from the second line of a paragraph with CSS

后端 未结 6 1183
轻奢々
轻奢々 2020-12-07 13:34

How can I indent starting from the second line of a paragraph?

I\'ve tried

p {
    text-indent: 200px;
}
p:first-line {
    text-indent: 0;
}
         


        
6条回答
  •  暖寄归人
    2020-12-07 14:06

    I needed to indent two rows to allow for a larger first word in a para. A cumbersome one-off solution is to place text in an SVG element and position this the same as an . Using float and the SVG's height tag defines how many rows will be indented e.g.

    Lorum Ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

    • SVG's height and width determine area blocked out.
    • Y=36 is the depth to the SVG text baseline and same as font-size
    • margin-top's allow for best alignment of the SVG text and para text
    • Used first two words here to remind care needed for descenders

    Yes it is cumbersome but it is also independent of the width of the containing div.

    The above answer was to my own query to allow the first word(s) of a para to be larger and positioned over two rows. To simply indent the first two lines of a para you could replace all the SVG tags with the following single pixel img:

    
    

提交回复
热议问题