我想知道如何在css中使一些按钮垂直堆叠而不是水平堆叠.
那么,html就像:
<button>Test<button>
<button>Test<button>
<button>Test<button>
Run Code Online (Sandbox Code Playgroud)
这些按钮默认是水平堆叠,我想要的是让它们垂直堆叠(所以每个人都在下一个按钮的顶部).
Ben*_*enM 13
将按钮定义为块级元素.另外,请注意使用正确的结束标记(</button>):
button {
display: block;
}Run Code Online (Sandbox Code Playgroud)
<button>Test</button>
<button>Test</button>
<button>Test</button>Run Code Online (Sandbox Code Playgroud)
<buttons>默认情况下是内联块元素。您可以通过将显示样式设置为阻止来更改它:
button {
display: block;
}Run Code Online (Sandbox Code Playgroud)
<button>Test</button>
<button>Test</button>
<button>Test</button>Run Code Online (Sandbox Code Playgroud)