解决问题之一:font-size 影响页面布局

为实现效果如下:

在这里插入图片描述

遇到的问题:

实现方法,border bottom+right 然后 nth(4n)没有没有 right
但是这样会造成一个问题div之前会有空隙,如下图:
在这里插入图片描述

为什么会遇到这个问题,怎么解决?

原因:因为页面默认的font-size字体大小影响了

解决:重置body,html{font-size:0}或者可以直接在当前元素的父元素设置font-size:0,因为全局设置可能会影响到页面的其它地方,会造成明明写了字怎么页面不显示的问题,即:0*0的情况,这点需要注意。

实现方式具体如下:

// html
<div class="apply-lists">
  <ul>
  	<li><img src="pic1.png" alt="logo"><p>滴滴出行</p></li>
  	<li><img src="pic2.png" alt="logo"><p>富途证券</p></li>
  	...
  </ul>
</div>
//css
.apply-lists{
    width: 95%;
    margin: 0 auto;
    text-align: center;
}
.apply-lists li{
    font-size: 14px;
    text-align: center;
    line-height:19px;
    color: #535353;
    font-family:MicrosoftYaHei-Bold;
    display: inline-block;
    font-weight: bold;
    width: 24%;
    margin: 0 auto;
    border-bottom: 1px solid#ECECEC;
    border-right: 1px solid#ECECEC;
    position: relative;
    padding: 3% 0;
}
.apply-lists li img{
  width: 124px;
  height: 40px;
}
.apply-lists li:nth-child(4),li:nth-child(8),li:nth-child(12){
    border-right: none;
}
.apply-lists li:nth-child(9),li:nth-child(10),li:nth-child(11),li:nth-child(12){
    border-bottom: none;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值