我正在尝试在div中导入用户的facebook朋友。 Friend Divs位置不正确。他们根据名称的长度四处乱逛。

Note:I was not able to show full name of friends because it was hard to fit in a small Friend Div.


的CSS

#jfmfs-friend-container {
    overflow:scroll;
    overflow-x: hidden;
    -ms-overflow-x: hidden;
    width:100%;
    height:7.6em;
    color: #333;
    background-color: #F7F7F7;
    padding-top: 10px;
}
.jfmfs-friend {
    cursor:pointer;
    float:left;
    height:3em;
    width:12em;
    font-size:11px;
    overflow:hidden;
    display:inline-block;
    margin-bottom: 0.40em;
}
.friend-name  {
    padding-left: 5px;
    width: 60px;
    font-weight: bold;
    color: #000;
    font-size: 12px;
}

.friend-checkbox {
    position: relative;
    vertical-align:middle;
    margin: 0px 0px 0px;
}

.friend-img {
    padding-left: 5px;
    width: 28px;
    height: 28px;
}


的HTML

<div id="jfmfs-friend-container">
<div class="jfmfs-friend  " id="00000000000"><input class="friend-checkbox" type="checkbox"><img src="//graph.facebook.com/000000000/picture" class="friend-img"><span class="friend-name">hhhhhHy uuuu</span></div>
<div class="jfmfs-friend  " id="00000000012"><input class="friend-checkbox" type="checkbox"><img src="//graph.facebook.com/00000000012/picture" class="friend-img"><span class="friend-name">hhhhhHy uuuu</span></div>
<div class="jfmfs-friend  " id="00000000330"><input class="friend-checkbox" type="checkbox"><img src="//graph.facebook.com/00000000330/picture" class="friend-img"><span class="friend-name">hhhhhHy uuuu</span></div>
<div class="jfmfs-friend  " id="00000000044"><input class="friend-checkbox" type="checkbox"><img src="//graph.facebook.com/00000000044/picture" class="friend-img"><span class="friend-name">hhhhhHy uuuu</span></div>
<div class="jfmfs-friend  " id="00000000880"><input class="friend-checkbox" type="checkbox"><img src="//graph.facebook.com/00000000880/picture" class="friend-img"><span class="friend-name">hhhhhHy uuuu</span></div>
<div class="jfmfs-friend  " id="00000000770"><input class="friend-checkbox" type="checkbox"><img src="//graph.facebook.com/00000000770/picture" class="friend-img"><span class="friend-name">hhhhhHy uuuu</span></div>
</div>


实际结果:

最佳答案

尝试将display:inline-block;添加到.friend-name

像这样-jsFiddle

.friend-name  {
    display:inline-block;
    padding-left: 5px;
    width: 70px;
    font-weight: bold;
    color: #000;
    font-size: 12px;
}

关于html - CSS:内部Divs的固定位置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15864052/

10-11 13:30