Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Can text-indent be set to a negative value in css?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about whether text-indent can be set to a negative value in css. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Text-indent can also be configured as a negative value. How tedious results can be achieved by using such tricks, such as "hanging indent", in which the first line is suspended on the right side of the rest of the element:

P {text-indent:-5em;}

However, be careful when setting negative values for text-indent equipment. If you configure a negative value for a paragraph, some of the text on the first line may exceed the left important place across the browser window. To resist this representation title, it is recommended to set an outer margin or some inner margin for negative indentation:

P {text-indent:-5em; padding-left: 5em;} percentage value

Text-indent can apply all units of length, including percentage values.

The percentage is related to the width of the parent element of the indented element. In other words, if the indent value is set to 20%, the first line of the affected element is indented by 20% of the width of its parent element.

In this case, the indent value is 20% of the parent element, or 100 pixels:

Div {width: 500px;} p {text-indent: 20%;}

This is a paragragh

Adhering to

The text-indent attribute can be adhered to, so consider the following tags:

Div#outer {width: 500px;} div#inner {text-indent: 10%;} p {width: 200px;} some text. Some text. Some text.

This is a paragragh.

The paragraph in the tag above will also be indented by 50 pixels, because this paragraph inherits the indentation value of the div element whose id is inner.

Thank you for reading! This is the end of the article on "can text-indent be set to negative in css". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report