[英]adjusting div content width to display content on multiple lines
如果父容器的寬度固定,並且您希望控制每行顯示多少個數字,則可以用div包裹數字並設置固定寬度:
.parent { background-color: grey; width: 500px; } .parent div { background-color: white; margin: 1px; width: 50px; display: inline-block; }
<div class="parent"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div>8</div> <div>9</div> <div>10</div> <div>11</div> <div>12</div> <div>13</div> <div>14</div> <div>15</div> </div>
您可以嘗試設置word-wrap
像這樣:
<div id="pageNo" style="width: 700px; word-wrap: break-word;">
1 2 3 4......
</div>
看看這個小提琴: https : //jsfiddle.net/9Ln3h3L2/1/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.