2022-10-22 364
这次给大家带来怎样使用li进行水平排列,使用li进行水平排列的注意事项有哪些,下面就是实战案例,一起来看一下。
li水平排列 html{ font-size: 20px; } @media only screen and (min-width: 320px){ html{font-size: 20px !important;} } @media only screen and (min-width: 350px){ html{font-size: 22.5px !important;} } @media only screen and (min-width: 365px){ html{font-size: 23px !important;} } @media only screen and (min-width: 375px){ html{font-size: 23.5px !important;} } @media only screen and (min-width: 390px){ html{font-size: 24.5px !important;} } @media only screen and (min-width: 400px){ html{font-size: 25px !important;} } @media only screen and (min-width: 428px){ html{font-size: 26.8px !important;} } @media only screen and (min-width: 432px){ html{font-size: 27.4px !important;} } @media only screen and (min-width: 481px){ html{font-size: 30px !important;} } @media only screen and (min-width: 569px){ html{font-size: 35px !important;} } @media only screen and (min-width: 569px){ html{font-size: 40px !important;} } body{ margin: 0; padding: 0; } ul{ width: 100%; margin: 0.3rem 0; padding:0.3rem 0; border-top:0.05rem solid #ccc; border-bottom: 0.05rem solid #ccc; } li{ width: 33%; list-style-type: none; display:inline-block; font-size: 0.8rem; border-left: 0.05rem solid #ccc; text-align: center; }
这样会有一个问题给li的宽度设置为33%,三个li标签的宽度居然超过了一行,有一点很明显就是li标签直接多了一点空白。
一、浮动
首先想到的是浮动,给li增加样式float:left。
效果如上,这样的方式,浮动会有一个问题,就是li的浮动使得ul的高度为0,解决这问题,有三种方法:
1、给ul增加height高度,但是这样不能做到自适应。
2、清楚浮动的影响,在最后的li标签后面增加一个空的p,
(个人推荐,但是觉得代码维护上也不是很好。)
3、对ul增加zoom属性,貌似只适应与ie(我没研究)。
二、将li标签写成一行
很奇怪为什么这样就正常了,暂时很难理解。
三、给ul增加样式去掉li标签之间空白
给ul增加font-size:0样式可以去除li标签之间的空白。这样有点需要注意的就是需要重新设置li标签的字体大小。
以上就是“怎样使用li进行水平排列 怎样进行数据排列”的详细内容,更多请关注77isp云服务器技术网其它相关文章!
原文链接:https://77isp.com/post/3645.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态