【HTML】元素垂直排列
2019-07-10 本文已影响0人
佐蓝Gogoing
writing-mode
样式可以控制文本在水平或垂直方向上如何排布,试了下,这里所说的文本应该不局限于文字,div 也可以:
<html>
<head>
<meta charset="utf-8"/>
<title>从上往下,从左往右</title>
<style>
html,body{ margin:0; border:0; padding:0; width:100%; height:100%; }
.parent{ display:block; background:gray; width:100%; height:100%; }
.parent{
writing-mode: vertical-lr;
}
.child{
margin:10px 10px 10px 10px;
border:5px solid black;
padding:5px;
width:50px;
height:50px;
text-align:center;
background:lightblue;
writing-mode: horizontal-tb;
display:inline-block;
}
</style>
</head>
<body>
<div class="parent">
<div class="child">1</div>
<div class="child">2</div>
<div class="child">3</div>
<div class="child">4</div>
<div class="child">5</div>
<div class="child">6</div>
<div class="child">7</div>
<div class="child">8</div>
<div class="child">9</div>
<div class="child">10</div>
<div class="child">11</div>
<div class="child">12</div>
<div class="child">13</div>
<div class="child">14</div>
<div class="child">15</div>
<div class="child">16</div>
<div class="child">17</div>
<div class="child">18</div>
<div class="child">19</div>
<div class="child">20</div>
<div class="child">21</div>
<div class="child">22</div>
<div class="child">23</div>
</div>
</body>
</html>