我想在<a>不使用的情况下将每个移动到一个新行<br>.
<div class="redirects">
<a href="http://google.com">1</a>
<a href="http://google.com">2</a>
<a href="http://google.com">3</a>
</div>
Run Code Online (Sandbox Code Playgroud)
您需要将显示重置为块级别值,或者浮动并清除或重置BFC并调整其大小.
有很多方法,只需使用最符合您需求的方法:
块
a {display:block;background:grey}Run Code Online (Sandbox Code Playgroud)
<div class="redirects">
<a href="http://google.com">1</a>
<a href="http://google.com">2</a>
<a href="http://google.com">3</a>
</div>Run Code Online (Sandbox Code Playgroud)
表
a {display:table;background:gray}Run Code Online (Sandbox Code Playgroud)
<div class="redirects">
<a href="http://google.com">1</a>
<a href="http://google.com">2</a>
<a href="http://google.com">3</a>
</div>Run Code Online (Sandbox Code Playgroud)
a {display:flex;background:gray}Run Code Online (Sandbox Code Playgroud)
<div class="redirects">
<a href="http://google.com">1</a>
<a href="http://google.com">2</a>
<a href="http://google.com">3</a>
</div>Run Code Online (Sandbox Code Playgroud)
a {float:left;clear:left;background:gray}Run Code Online (Sandbox Code Playgroud)
<div class="redirects">
<a href="http://google.com">1</a>
<a href="http://google.com">2</a>
<a href="http://google.com">3</a>
</div>Run Code Online (Sandbox Code Playgroud)
甚至内联块+宽度
a {display:inline-block;width:100%;background:gray}Run Code Online (Sandbox Code Playgroud)
<div class="redirects">
<a href="http://google.com">1</a>
<a href="http://google.com">2</a>
<a href="http://google.com">3</a>
</div>Run Code Online (Sandbox Code Playgroud)