2016-10-27 172 views
1

我有帶標籤的單選按鈕輸入,但是我無法水平對齊它,它只是一個接一個垂直出現,我怎麼才能讓它水平對齊。如何水平對齊單選按鈕

<div class="cc-selector-2" align="right"> 
     {{range $index,$url := .Avatars}}            
     <label for="pic1">                 
     <input type="radio" name="avatar" id={{$url}} value={{$url}} />    
     <img src={{$url}} alt="" height="40" width="40"/>                         
     </label> 
     {{end}} 
</div> 

<style>  
.cc-selector-2 input{ 
    position:absolute; 
    z-index:999; 
} 

    label { 
     display: block; 
     text-align: center; 
     margin-bottom:0px; 
     font-size: .85em; 
     background-color:buttonface; 
    } 

</style> 
+0

把完整的代碼。 – Afsar

回答

0

與顯示剛玩:inline-block的;)

cc-selector-2{ 
 
    text-align: center; 
 
} 
 

 
label { 
 
    display: inline-block; 
 
    margin:auto; 
 
    font-size: .85em; 
 
    background-color:buttonface; 
 
} 
 

 
input { 
 
    margin: 0; 
 
}
<div class="cc-selector-2" align="right"> 
 
    <label for="pic1"> 
 
     <input type="radio" name="avatar" id={{$url}} value={{$url}} />   
 
     <img src={{$url}} alt="" height="40" width="40"/> 
 
    </label> 
 
    <label for="pic1"> 
 
     <input type="radio" name="avatar" id={{$url}} value={{$url}} />   
 
     <img src={{$url}} alt="" height="40" width="40"/> 
 
    </label> 
 
</div>