CSS force new line

2019-03-11 17:51发布

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.

4条回答
干净又极端
2楼-- · 2019-03-11 18:09

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;
}
查看更多
\"骚年 ilove
3楼-- · 2019-03-11 18:18

Use <br /> OR <br> -

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

OR

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

or

make the a element display:block;

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

Try

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-03-11 18:21

How about with a :before pseudoelement:

a:before {
  content: '\a';
  white-space: pre;
}
查看更多
孤傲高冷的网名
5楼-- · 2019-03-11 18:30

or you can use:

a {
    display: inline-block;
  }
查看更多
登录 后发表回答