Reply to comment

CSS selectors 101 or How to hide your edit links for a view displayed as a block

While I have worked with css, I never do it long enough, or frequently enough to really remember it well.  At this point, I can always remember the difference between the ID selectors and the class selectors, but I just forgot how to combine them into a single css rule.

Give the following html, how would you write some css to hide the UL?

<div id="block-views-view_checklist_for_user-block_1">
   <div class="views-admin-links">
       <ul>
         <li><a href="edit">Edit</a></li>
       </ul>
   </div>
</div>
<div id="block-views-view_checklist_for_user-block_2">
   <div class="views-admin-links">
       <ul>
         <li><a href="edit">Edit</a></li>
       </ul>
   </div>
</div>

This is the css, notice how each combination of the id and class selector is separated by a comma.

/* hide admin links for views in blocks */ 
#block-views-view_checklist_for_user-block_1 .views-admin-links ul, #block-views-view_checklist_for_user-block_2 .views-admin-links ul
{ display:none; }

Explanation,
  • The 2 main divs in this case, each have an id of block-views-view_checklist_for_user-block_1 and block-views-view_checklist_for_user-block_, so we use the "#" id selector to begin with
  • The next selector is the class "view-admin-links", which we prepend a "." to
  • The UL is the last html element.

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options