css - 多个span 元素怎么在容器大小差不多总会掉下来
天蓬老师
天蓬老师 2017-04-17 13:51:58
0
3
731

topp{

    
            position: absolute;
            background-color: white ;
            height:64px;
            top:0;    
            left:50%;            
            width:501px;                
            margin-left: -250px;             

            }            
            #topp span{
                display:inline-block;                
                width:100px;                
                font-size:24px;
                height:32px;                    
            }
            希望每行显示5个,却四个就掉下了了width设为550倒是可以,却又空出50px...
            
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(3)
左手右手慢动作

display: There will be a character gap between the inline-block elements, and this gap causes the last one to fall down.

Solution:
1. Set font-size for the parent element: 0px;
2. Cancel the line break, like this: <span>aaaa</span><span>aaaa</ span><span>aaaa</span>continuous.

或者
<p class="space">
    <a href="##">惆怅</a><!--
    --><a href="##">淡定</a><!--
    --><a href="##">热血</a>
</p>

<p class="space">
    <a href="##">惆怅</a
    ><a href="##">淡定</a
    ><a href="##">热血</a>
</p>

3. Use negative margin values.
4. Use float.
5. There are also methods such as letter-spacing and word-spacing.

小葫芦

You can take a look at the grid system of frameworks similar to bootstrap.

左手右手慢动作

Set font-size: 0px to the parent element; it is very effective

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template