CSS规则实现:溢出

时间:2016-04-06 01:01:35

标签: html css

我想为p.com的网页创建一条规则

  1. 在溢出到下一行之前将一行文本限制为80个字符。
  2. 缩进溢出的每行文本(每行超过80个字符。)
  3. 到目前为止,我有:

    p.comment {
        padding-top: 5px;
        padding-bottom: 5px;
        width: 80ch;
        text-indent: 4ch;
    }  
    

    问题是上面的代码只缩进第一行,但我希望它不缩进第一行,但缩进所有行除了第一行。

    我试图在Google上看到解决方案,但我正在努力制定它。搜索“html indent overflow”或“html indent paragraph overflow”似乎没有给我答案,我可以理解。

    实施例

    之前(特别感谢http://uncyclopedia.wikia.com/wiki/Wall_of_Text

    A wall of text is something that is frowned upon in most, actually virtually all Internet societies, including forums, chat boards, and Uncyclopedia. You should not make walls of text because it can get you banned anywhere unless it is a place that encourages walls of text. I highly doubt any place does support something so irritating and annoying, but anything can exist, but not really because unless you are in heaven then that can happen. But no one actually knows that was just a hypothesis, a lame one that is. Actually not really lame. You can create a wall of text supporting site, but you would be hated if you do that, so do not. But you can if you like, but I discourage that. Now on to the actual information of walls of texts. The wall of text was invented when the Internet was invented, but actually it was slow at that time. So whenever it became fast. But there would need to be some free or not free community for people, and that community would be able to have walls of text. But that community probably wouldn't have actually invented the wall of text.
    

    A wall of text is something that is frowned upon in most, actually virtually all
        Internet societies, including forums, chat boards, and Uncyclopedia. You 
        should not make walls of text because it can get you banned anywhere unless 
        it is a place that encourages walls of text. I highly doubt any place does
        support something so irritating and annoying, but anything can exist, but 
        not really because unless you are in heaven then that can happen. But no 
        one actually knows that was just a hypothesis, a lame one that is. 
        Actually not really lame. You can create a wall of text supporting site, but
        you would be hated if you do that, so do not. But you can if you like, but I
        discourage that. Now on to the actual information of walls of texts. 
        The wall of text was invented when the Internet was invented, but actually 
        it was slow at that time. So whenever it became fast. But there would need 
        to be some free or not free community for people, and that community would 
        be able to have walls of text. But that community probably wouldn't have 
        actually invented the wall of text. 
    

    这个想法是通过将段落长度限制为80个字符,和 迫使它在每一个新行上缩进,我避免做正常的工作 通过将每个80个字符的段落包装成自己的段落来完成 span,很快就会损害阅读网页实际代码的能力。

    当然,理想情况下,段落也应该变成警告信息,例如“如果长度超过4行,则此段落太长而无法呈现”,因为这使得该段落对于许多到达终点的人来说是不可读的该行并忘记了他们所在的行,但我认为如果没有JavaScript,这是可能的。

    如果上述情况可能没有Javascript,我也想知道如何做到这一点。

    提前致谢。

2 个答案:

答案 0 :(得分:2)

喜欢这个吗?



p.comment {
    padding-top: 5px;
    padding-bottom: 5px;
    padding-left:4ch;
    border-left: 3px solid var(--color-comment);
    width: 80ch;
    taxt-align: start;
    text-indent: -4ch;       
}  

<p class="comment">
A wall of text is something that is frowned upon in most, actually virtually all Internet societies, including forums, chat boards, and Uncyclopedia. You should not make walls of text because it can get you banned anywhere unless it is a place that encourages walls of text. I highly doubt any place does support something so irritating and annoying, but anything can exist, but not really because unless you are in heaven then that can happen. But no one actually knows that was just a hypothesis, a lame one that is. Actually not really lame. You can create a wall of text supporting site, but you would be hated if you do that, so do not. But you can if you like, but I discourage that. Now on to the actual information of walls of texts. The wall of text was invented when the Internet was invented, but actually it was slow at that time. So whenever it became fast. But there would need to be some free or not free community for people, and that community would be able to have walls of text. But that community probably wouldn't have actually invented the wall of text.
</p>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

使用:

text-indent: -4ch;
padding-left: 4ch;

div{
  text-indent: -4ch;
  padding-left: 4ch;
}
<div>
  A wall of text is something that is frowned upon in most, actually virtually all Internet societies, including forums, chat boards, and Uncyclopedia. You should not make walls of text because it can get you banned anywhere unless it is a place that encourages
  walls of text. I highly doubt any place does support something so irritating and annoying, but anything can exist, but not really because unless you are in heaven then that can happen. But no one actually knows that was just a hypothesis, a lame one
  that is. Actually not really lame. You can create a wall of text supporting site, but you would be hated if you do that, so do not. But you can if you like, but I discourage that. Now on to the actual information of walls of texts. The wall of text
  was invented when the Internet was invented, but actually it was slow at that time. So whenever it became fast. But there would need to be some free or not free community for people, and that community would be able to have walls of text. But that community
  probably wouldn't have actually invented the wall of text.
</div>