2013-04-07 4 views
0

Я пытаюсь импортировать друзья пользователя facebook в div. Friend Divs расположены неправильно. Они смеются вокруг по длине имени.CSS: фиксированное положение внутренних разделов

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> 

Фактический результат: enter image description here

+0

Ваш HTML не является действительным. Атрибут id не может содержать # и не должен начинаться с числа. – ZippyV

ответ

2

Попробуйте добавить display:inline-block; к .friend-name

как this- jsFiddle

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

Это трюк, но теперь появляются полные имена и не вписываются в высоту div. Имена друзей здесь проблемы, они могут быть очень длинными, так что просто хотите, чтобы имя, если они не вписываются в div. –

+0

В вашей скрипке тоже высота имени больше, чем высота изображения. –

+0

Попробуйте это http://jsfiddle.net/apaul34208/Yyjxe/1/ – apaul