简体   繁体   English

CSS选择器SharePoint 2010

[英]Css selectors SharePoint 2010

I have the following html structure: 我有以下html结构:

<div class="ms-PostFooter">

<span style="">
<span style="" class="s4-clust">
<a href="#" style="">
<img src="" alt="" style="l" title="" class="imglink" longDesc="" />
</a>
</span>
</span>

<span style="">
<span class="s4-clust">
<a href="#" style="">
<img src="" alt="" style="" title="" class="imglink" longDesc="" />
</a>
</span>
</span>

<span style="">
<span class="s4-clust">
<a href="#" style="">
<img src="" alt="" style="" title="Number of Comments" class="imglink" longDesc="" />
</a>
</span>
</span>

</div>

In css how would I select the third tag in order to hide the image with title "Number of Comments"? 在CSS中,我如何选择第三个标签以隐藏标题为“ Number of Comments”的图像?

.ms-PostFooter span::nth-child(3) img {
    display: none;
}

or this also works: 或者这也可以:

img[title="Number of Comments"] {
    display: none;
}

however these rely on your markup / content. 但是这些取决于您的标记/内容。 the best way would be - generate a specific class on that image or its container, server-side (if you can) 最好的方法是-在服务器端在该图像或其容器上生成特定的类(如果可以)

One possibility if your title is unique: 如果标题是唯一的一种可能性:

[title="Number of Comments"]
{
    display:none;
}

You can use the following: 您可以使用以下内容:

div :last-child span .imglink{
   display:none;
}

jsfiddle: http://jsfiddle.net/kGThS/1/ jsfiddle: http : //jsfiddle.net/kGThS/1/

This may be more specific: 这可能更具体:

.ms-PostFooter :last-child span .imglink{
   display:none;
}

jsfiddle: http://jsfiddle.net/kGThS/3/ jsfiddle: http : //jsfiddle.net/kGThS/3/

To hide the entire last span/link as per your comment below use the following: 要按照下面的注释隐藏整个最后一个跨度/链接,请使用以下命令:

.ms-PostFooter :last-child span{
   display:none;
}

Somehow through css sharepoint was not allowing me to use any of the selectors mentioned here through css to get rid of the specif tag containing the link and image to be removed so I decided to use jquery instead which did the trick as follows: 通过css共享点以某种方式不允许我使用通过css此处提到的任何选择器来摆脱包含要删除的链接和图像的specif标签,因此我决定使用jquery来代替,该方法如下:

$( document ).ready(function() {
$('DIV.ms-PostFooter span:nth-child(3)').css('display', 'none');
$('DIV.ms-PostFooter span:nth-child(4)').css('display', 'none');

});

Thanks for all the assistance. 感谢您的协助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM