CSS 强制换行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17721031/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 23:33:53  来源:igfitidea点击:

CSS force new line

csscss-floatnewline

提问by Sebastian Starke

I have something like this:

我有这样的事情:

<li>Post by <a>Author</a></li>

And I want to display the link in a new line, like this

我想在新行中显示链接,就像这样

Post by
Author

How can I achieve this? Clear:left doesn't work.

我怎样才能做到这一点?清除:左不起作用。

回答by Shiva Avula

Use the display property

使用显示属性

a{
    display: block;
}

This will make the link to display in new line

这将使链接显示在新行中

If you want to remove list styling, use

如果要删除列表样式,请使用

li{
    list-style: none;
}

回答by alxndr

How about with a :beforepseudoelement:

:before伪元素怎么样:

a:before {
  content: '\a';
  white-space: pre;
}

回答by Ya Basha

or you can use:

或者你可以使用:

a {
    display: inline-block;
  }

回答by Ishan Jain

Use <br />OR <br>-

使用<br /><br>-

<li>Post by<br /><a>Author</a></li>

OR

或者

<li>Post by<br><a>Author</a></li>

or

或者

make the aelement display:block;

制作a元素display:block;

<li>Post by <a style="display:block;">Author</a></li>

Try

尝试