2016-10-09 37 views
1

好吧,我试图解决这个我自己,但好像很多人都对所有种类的不同原因,同样的问题,所以这里是我的情况:SCSS:文本对齐不工作

<div class="col-md-4"> 
 
    <ol class="albums"> 
 
    <%= render @albums %> 
 
    </ol> 
 
    <%= will_paginate @albums %> 
 
</div>

@album:

<li id="album-<%= album.id %>" class="listed_album"> 
 
    <div class=row> 
 
    <aside class="col-md-6" id="album_cover"> 
 
     <% if album.clips.any? %> 
 
     <%= link_to album do %> 
 
      <img src="http://img.youtube.com/vi/<%= album.clips.first.adress %>/mqdefault.jpg" height="110" width="178"> 
 
     <% end %> 
 
     <% else %> 
 
     <%= link_to album do %> 
 
      <img src="http://img.youtube.com/vi/ksjfhskd4/0.jpg" height="110" width="178"> 
 
     <% end %> 
 
    <% end %> 
 
    </aside> 
 
    <div class="col-md-6" id="album_info"> 
 
     <p><span class="title"><%= album.title %></span></p> 
 
     <span class="likes"> 
 
        <%= pluralize(Album.find(album_to_display).relationships.where(value: 1).count, "like") %> | 
 
        <%= pluralize(Album.find(album_to_display).relationships.where(value: -1).count, "dislike") %> 
 
     </span> 
 
    </div> 
 
    </div> 
 
</li>

我想在其左上角(顶部和底部相对于左上角的图片高度)的顶部和中心的标题,但直到现在我是只能用padding-right:15px;例如。我该如何调整它,才能使文本对齐:center;或浮动:底部;工作?

li.listed_album { 
 
    #album_info { 
 
    span.title { 
 
     text-align: center; 
 
    } 
 
    span.likes { 
 
     float: bottom; 
 
    } 
 
    } 
 
}

+0

请提供jS小提琴。 –

回答

0

很难说没有能够看到它的jsfiddle或codepen ..你试过这样:

li.listed_album { 
    #album_info { 
    text-align: center; 
    } 
    span.likes { 
     float: bottom; 
    } 
} 

或只是让#album_info一个Flexbox的:

#album_info { 
    display:flex; 
    justify-content: center; 
}