Closed. This question needs details or clarity。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
                        
                        4年前关闭。
                                                                                            
                
        
我有这个HTML

<div id="NBSAreaDirectorySearch">
    <div class="ms-webpart-chrome ms-webpart-chrome-fullWidth ">
        <div class="ms-WPBody " id="WebPartWPQ2" allowdelete="false" onlyformepart="true" width="100%" haspers="true" webpartid="00000000-0000-0000-0000-000000000000">
            <div style="display: none;"></div>
            <div id="ctl00_PlaceHolderMain_g_2ea1c174_49f1_467b_89ff_d32d6c945151_csr" componentid="ctl00_PlaceHolderMain_g_2ea1c174_49f1_467b_89ff_d32d6c945151_csr">
                <div class="ms-floatLeft" id="SearchBox" name="Control">
                    <div class="ms-srch-sbLarge ms-srch-sb-border nbs-landingAreaDirectory-srchBoxDiv" id="ctl00_PlaceHolderMain_g_2ea1c174_49f1_467b_89ff_d32d6c945151_csr_sboxdiv">
                        <input title="Search within the Branch Directory">
                        <a title="Search">
                            <img id="searchImg">
                        </a>
                        <div>
                            <div>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="SearchOptions">
                </div>
            </div </div>
            <div class="ms-clear">
            </div>
        </div>
    </div>
</div>


NBSAreaDirectorySearch以下的所有内容都是自动生成的,因此除了searchImg之外,id可能有所不同。我想通过searchImg更改nbsareadirectorysearch的css,因为页面上还有另一个searchImg
SharePoint网站,因此母版页中有一个searchimg,页面布局中有一个。不幸的是,我无法更改其自动生成的ID

最佳答案

您应该只能够使用

#NBSAreaDirectorySearch #searchImg {
    border: red 1px solid;
}


Here's a fiddle使用您发布的内容。我使用了一个占位符图像来突出显示所应用的红色边框样式。

10-04 13:52