qq_40133235 2021-01-12 17:07 采纳率: 50%
浏览 133
已采纳

在css中设置图片的样式:font-size:0;为什么会改动字到图片的距离

<a class="s_c_img" href="">
    <img src="jQuery实战-小米官网的开发_files/2(4).jpg" alt="" width="160px" height="160px">  
</a>
<a class="s_c_title" href="">小米体重秤</a>
<p class="s_c_detail">高精度压力传感器,手机管理全家健康</p>
#smart .s_content ul .s_c_bottom .s_c_img{
    font-size: 0;/* 这是设置了font-size:0;的*/
    text-align: center;
    display: block;
    padding: 20px 35px;
}
#smart .s_content ul .s_c_bottom .s_c_title{
    text-align: center;
    display: block;
    font-size: 14px;
    color: #000;
}
#smart .s_content ul .s_c_bottom .s_c_detail{
    font-size: 12px;
    text-align: center;
    color: #999;
    margin: 5px 0 13px 0;
}

#smart .s_content ul .s_c_bottom .s_c_img{
    /* font-size: 0; */这个是未设置font-size:0;的样式
    text-align: center;
    display: block;
    padding: 20px 35px;
}
#smart .s_content ul .s_c_bottom .s_c_title{
    text-align: center;
    display: block;
    font-size: 14px;
    color: #000;
}
#smart .s_content ul .s_c_bottom .s_c_detail{
    font-size: 12px;
    text-align: center;
    color: #999;
    margin: 5px 0 13px 0;
}

这两者有细微的差别,为什么会有这样的差别?希望大佬可以帮忙告诉下,谢谢!!!

  • 写回答

2条回答 默认 最新

  • 鲤鲤鲤carp 2021-01-12 17:49
    关注

    因为bolck,inline-block中 自带一个空格缝隙,你把它设为font-size:0 ,就把缝隙消除了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计