Choosing items within a category

For quite some time now, a question has been bothering me. I've been delving deeper into CSS lately and have made the decision to avoid using jQuery in this Drupal project to stay clear of custom code.

The issue arises with a class that is applied to the BODY element called "not-logged-in" when the user is not logged in. In theory, this should work smoothly for us since only admins can log in. However, problems occur when someone is editing a node - all our custom classes are loaded in both scenarios, resulting in some editing controls appearing distorted.

The BODY style looks like this:

<body class="html not-front not-logged-in no-sidebars page-node page-node- page-node-1 node-type-page footer-columns" >

    ... [significant body content here--other divs, other classes, elements with IDs] ...

    <div class='mycustomclass'>Should be bigger if logged in</div>
</body>

When attempting to add a CSS directive and style, such as:

.not-logged-in .mycustomclass {
    font-size: 20px;
}

The style seems to overlook .mycustomclass. I have encountered this issue before but always brushed it off as my lack of CSS expertise. Additionally, with jQuery available, it was never a pressing concern. It would greatly help if someone could finally solve this perplexing mystery for me.

Answer №1

Your code structure looks good, no issues there.

There could be a couple of reasons for the problem you're facing:

  1. The class might not be loading properly, either on the body tag or on your specific mycustomclass element. Make sure to double-check in the browser-rendered source, as Drupal caching could be causing your changes not to show up. Don't forget to clear the Drupal cache.

  2. It's possible that specificity is the issue. Another class on the element or a global rule might be overriding your CSS styles on that particular element.

To address these issues, make use of tools like Firebug and the Web Developer Toolbar in Firefox. These tools are extremely useful for debugging CSS problems.

Answer №2

Ensure that Drupal is inserting the css script tags within the <head> section of your HTML code. They should come after your stylesheet references. It's important for the Drupal css (which adds the not-logged-in class to the <body>) to be executed before your own css.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Enhancing the appearance of unvisited links with background styles

I am endeavoring to incorporate an icon into all unvisited links on a specific Wordpress category page. Below is the CSS code that I am utilizing. It has been placed at the conclusion of my final CSS file. .category-xyzzy .entry-title a:link { background ...

Using Flexbox to ensure two elements do not appear next to each other

When viewing on large screens, I want all elements to be on one row. On smaller screens, I want them to be on three rows. Specifically, I don't want to see the button next to the H1 element on the same row. How can flexbox help solve this problem? Tha ...

Maintaining Consistent Image Heights in Bootstrap Figure Rows

Within a column in a row, I have two images per row. Users can upload their own images without them being cropped to specific dimensions. The images are uploaded at their original dimensions. However, on the frontend, this is causing some images to appear ...

Enhancing the appearance of a JSX component in React

I have a segment of code within my project that calculates a specific percentage and displays it on the dashboard. <text className="netProfit-circle-text" x="50%" y="50%" dy=".2em" textAnchor="middl ...

jQuery Toggle and Change Image Src Attribute Issue

After researching and modifying a show/hide jQuery code I discovered, everything is functioning correctly except for the HTML img attribute not being replaced when clicked on. The jQuery code I am using: <script> $(document).ready(function() { ...

Inserting JQuery Selector from a .js file into a .php file at the beginning

Incorporated in my project is a jquery plugin for a slider, which includes the code snippet below for handling 'next and prev' buttons. $(selector).prepend('\ <ul class="mk-nav-controls">\ <li>& ...

What is the most effective way to implement a single modal throughout my web application without having to duplicate HTML code on each page?

After realizing I was repetitively adding the same div to every page for a modal dialog, I decided to place a single div in the site.master page and call it when needed. This method worked fine until I began implementing ajax with partial page updates. H ...

Tips on how to prevent a video from playing in the background of a popup even after it has been closed

After creating a video popup that plays upon clicking a button using jQuery, I encountered an issue where the video continues to play in the background even after closing the popup by clicking the close(X) button. Below is my code, can someone assist me in ...

Tips for aligning pagination in the center in bootstrap 4

What is the best way to centrally align pagination in Bootstrap 4? I have tried adding the code, but the pagination remains aligned to the left instead of the center. Even when applying the text-center class to the parent element, it does not work as exp ...

CSS Lower does correlate with an item

<body> ...additional content... <div style="width: 30px; margin-left: 500px; bottom: 0px;"> <img src="picture.png"> </div> </body> Although the margin-left is functioning properly, I am having trouble getting the picture ...

How to ensure Angular mat-button-toggle elements are perfectly aligned within their respective groups

https://i.stack.imgur.com/Wjtn5.png Hello there, I'm trying to make the numbers in the first group match the style of the second group (noche, mañana...). I've set both the group and individual element width to 100%, but the numbers beyond 22 ...

position an element at a higher level than the #top-layer

I developed a custom tool and utilized z-index to position it above all other elements: .customTool { position: fixed; z-index: 99999; } However, this functionality stops working when a modal <dialog /> element is opened in modal mode. As a res ...

What is the best way for me to locate and access the initial element that has been assigned the

How do I reference the first element with the "myabilities" class in the code snippet below? <div class="span6"> <h3 class="srvc-title">Responsive Design</h3> <p class="srvc-detail">Crafting great experie ...

When resizing the window, navigation items vanish

I've implemented the collapse feature using Bootstrap, but encountered an issue where my nav elements disappear when resizing the window. Do you have any suggestions on how to fix this? Here's a snippet of my code: Navb ...

Opting for a name selector over an id for more specific styling

Is there a way to modify the code below in order to make it function based on a name selector instead of an id? <div id="light" class="change_group_popup"> <a class="close" href="javascript:void(0)">Close</a> JavaScript $('.ch ...

Using jQuery to reveal and conceal elements upon hover interaction

I have implemented a basic jquery function to display and hide a div when hovering over an anchor. However, the issue I am facing is that the div disappears when I move my cursor away from the anchor tag. I want to be able to interact with the div without ...

Tips for adjusting the size of an HTML canvas to fit the screen while preserving the aspect ratio and ensuring the canvas remains fully visible

I'm working on a game project using HTML canvas and javascript. The canvas I am using has dimensions of 1280 x 720 px with a 16:9 aspect ratio. My goal is to have the game displayed at fullscreen, but with black bars shown if the screen ratio is not 1 ...

Trouble arises when trying to link IE7 with jQuery

I am currently testing a website with jQuery. There is a plugin that, when hovered over, slides down to reveal another banner, subsequently sliding the banner below it down as well. I have added a link on the bottom banner using z-index, and although it wo ...

The image overlay in the div remains fixed in a large screen size but does not stack when the screen size

Sorry for the not-so-great title, I'm still learning the terminology. I have a situation where a div is covering part of a background image when the screen is wide. However, on smaller screens, I want that div to move below the background image inste ...

Issue with navigating previous and next slides in Bootstrap carousel

I'm currently facing an issue where when I try to navigate left/right through pictures on my page, it ends up moving slightly downwards instead. Despite following a tutorial to resolve this problem, there seems to be a missing piece of code that I can ...