Guest User

Untitled

a guest
Apr 21st, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. ## BAD
  2.  
  3. # This is invalid because the div (block level elment) is inside of the span (in-line element), and it displays/prints a div that in this case isn't needed for element positioning, and really it should be omitted. Note that because we are using a separate print stylesheet unless we add the easyAdd definition to the print stylesheet we won't actually see the div's styling when we print the page.
  4.  
  5. <span class="noprint">
  6. <% if current_user.role.manage_community_classes? %>
  7. <div id="easyAdd"><%= link_to 'Add a Class', new_community_class_path %></div>
  8. <% end %>
  9. </span>
  10.  
  11.  
  12. ## GOOD, BUT...
  13.  
  14. # This validates, but it still prints the div...
  15.  
  16. <% if current_user.role.manage_community_classes? %>
  17. <div id="easyAdd"><span class="noprint"><%= link_to 'Add a Class', new_community_class_path %></div></span>
  18. <% end %>
  19.  
  20.  
  21. ## IDEAL
  22.  
  23. # This validates and doesn't print the div. The only problem is that if the div is already using a class it can't also use the "noprint" class, so... we lucked out here... and this is idea for situations like this... but the above example may need to be used in situations where a div class is already specified
  24.  
  25. <% if current_user.role.manage_community_classes? %>
  26. <div id="easyAdd" class="noprint"><%= link_to 'Add a Class', new_community_class_path %></div>
  27. <% end %>
  28.  
  29.  
  30. ## How else could all this be done?
  31.  
  32. # print.css could contain all of the same div definitions from screen.css that we do not want to print, but would need to use display:none; for each to keep them from printing.
Add Comment
Please, Sign In to add comment