Home >Web Front-end >HTML Tutorial >In html, let multiple li of ul be displayed in one line_html/css_WEB-ITnose
Sometimes it is necessary to display the li of ul on the same line to prevent the li from running to the next line. I encountered this problem today. Record it to avoid forgetting~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Document</title> <style type="text/css"> *{ padding: 0; margin-bottom:0; border: 0; } .box{ width: 640px; height: 50px; overflow-x: scroll; overflow-y: hidden; } ul{ display:inline; white-space: nowrap; } ul li{ padding: 10px 20px; display: inline-block; background:pink; white-space:nowrap; } </style></head><body><div class="box"> <ul> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> <li>所有li都在一行显示</li> </ul></div></body></html>
The effect is as shown below:
I just wrote it casually, it’s so ugly, don’t pay attention to the details hahaha~~~~