2017-10-04 27 views
1

我有這樣的HTML SharePoint Online中:自定義列寬

<div sortable="" 
    sortdisable="" 
    filterdisable="" 
    filterable="" 
    filterdisablemessage="" 
    name="Responsable" 
    ctxnum="14" 
    displayname="Responsable" 
    fieldtype="User" 
    resulttype="" 
    sortfields="View={6ae319f0-c398-4d0a-b737-b3214732035b}&amp;SortField=Responsable&amp;SortDir=Asc" 
    class="ms-vh-div"> 

我試過像jQuery來改變它:

$("input[title='Responsable']").css({ 
'width':'400px', 

}); 

或者:

$("div[name='Responsable']").css({ 
'width':'400px', 

}); 

使用CSS我試着:

.ms-vh-div [DisplayName='<Responsable>'] 
{ 
width : 1000px !important; 
} 

但這些都沒有工作。我怎樣才能改變這個div的寬度?

+1

第二代碼將工作的,肯定 –

+0

儘量把你的第二個選項裏面這樣:$(文檔).ready(function(){ //您的第二個選項 }); –

+0

沒有'title'屬性,它是一個'div'而不是'input',所以第一個將不起作用。第三個應該是'displayname',而不是'DisplayName',並且類名和括號之間不應有空格。 –

回答

2

你的第二個代碼將工作,如果: -

1.You將新增關閉</div>

2.在腳本代碼之前添加jQuery庫。

3.Wrap代碼中$(document).ready({...});

檢查下面的代碼片段: -

$(document).ready(function(){ 
 
    $("div[name='Responsable']").css({'width':'400px'}); 
 
});
div{ 
 
    background:red; /* to show you that width is actually increasing */ 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div sortable="" sortdisable="" filterdisable="" filterable="" filterdisablemessage="" name="Responsable" ctxnum="14" displayname="Responsable" fieldtype="User" resulttype="" sortfields="View={6ae319f0-c398-4d0a-b737-b3214732035b}&amp;SortField=Responsable&amp;SortDir=Asc" class="ms-vh-div">1</div>