简体   繁体   English

内联块元素之间的空白

[英]White space between inline-block elements

I feel like this question shouldn't exist anymore, but I can't seem to find a solution. 我觉得这个问题不应该再存在了,但是我似乎找不到解决方法。 So here goes. 所以去。

 ul { list-style-type: none; width:150px; } ul.nav_sub_menu > li { width: 100%; } ul.nav_sub_menu > li a { display: inline-block; width: 100%; padding: 2.5px 0px 2.5px 5px; background: #213059; color: white; text-decoration: none; border-bottom: 5px solid #253767; } ul.nav_sub_menu > li a:hover { text-decoration: underline; background-color: #253767; } 
 <div class="nav_sub_menu_wrapper"> <ul class="nav_sub_menu"> <li> <a href="javascript:void(0)" class="nav_sub_button">About me</a></li><li> <a href="javascript:void(0)" class="nav_sub_button">Goals</a></li><li> <a href="javascript:void(0)" class="nav_sub_button">Realizations</a></li><li> <a href="javascript:void(0)" class="nav_sub_button">Future plans</a></li> </ul> </div> 

This example generates a styles list with display:inline-block anchor tags You might notice from the start that each list-item is separated by a horizontal white line between them. 此示例生成带有display:inline-block锚标记的样式列表。您可能从一开始就注意到,每个列表项之间都用一条水平的白线隔开。 If not, try zooming the browser in or out (visible at 110% for me). 如果没有,请尝试放大或缩小浏览器(对我而言,可见度为110%)。

The white space isn't visible at all zoom levels and it only happens in Chrome, that's why I am at a loss. 空白并不是在所有缩放级别上都可见,并且仅在Chrome中发生,这就是我茫然的原因。 How does one begin to troubleshoot this? 如何开始对此进行故障排除?

在此处输入图片说明

FYI, I have found this link to be useful but it didn't help. 仅供参考,我发现此链接很有用,但没有帮助。 My chrome version: 我的Chrome版本:

Chrome Version 56.0.2924.87 (64-bit) Chrome版本56.0.2924.87(64位)

That is a weird issue. 这是一个奇怪的问题。 I think it might be something to do with the pixel resolution or density perhaps. 我认为这可能与像素分辨率或密度有关。 However I managed to fix it with the below code. 但是我设法用下面的代码修复了它。

ul {
    list-style-type: none;
    width:150px;
}
ul.nav_sub_menu > li {
    width: 100%;
}

ul.nav_sub_menu > li a {
    display: inline-block;

    width: 100%;
    padding: 2.5px 0px 2.5px 5px;

    background: #213059;

    color: white;
    text-decoration: none;

    border-bottom: 5px solid #253767;
    float: left;
}

ul.nav_sub_menu > li a:hover {
    text-decoration: underline;
    background-color: #253767;
}

All I added was float: left; 我只添加了float: left; to the anchor property and it removed the white line between the list items. 锚属性,它删除了列表项之间的白线。 Try it and see what it does for different zoom levels. 尝试一下,看看它对不同的缩放级别有什么作用。 Although it does work for 110% zoom for me. 虽然它对我来说可以放大110%

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM