The :not() CSS selector does not function properly during the initial loading of a webpage

This particular CSS code rotates an SVG upward pointing arrow by 180 degrees only when the header does not possess the .collapsed class:

.IRE-content__header:not(.collapsed) svg {
    transform: rotate(180deg);
}

However, an issue arises when the page is initially loaded and none of the headers have the .collapsed class. The rotation effect only takes place after removing the .collapsed class from a header.

This CSS modification is intended for a Bootstrap 4 accordion component.

Answer №1

Elements displayed inline won't be rotated. Make sure your SVG is set to display:inline-block

Here's a simple example:

.IRE-content__header:not(.collapsed) svg {
  transform: rotate(45deg);
  color: red;
  display: inline-block;
}
<div class="IRE-content__header collapsed"><svg viewBox="0 0 220 100" xmlns="http://www.w3.org/2000/svg">
  <!-- Yellow rectangle displayed here -->
  <rect x="0" y="0" width="100" height="100" fill="skyblue"></rect>
  <rect x="20" y="20" width="60" height="60" fill="yellow"></rect>

  
</svg></div>
<div class="IRE-content__header"><svg viewBox="0 0 220 100" xmlns="http://www.w3.org/2000/svg">
  <!-- Yellow rectangle displayed here -->
  <rect x="0" y="0" width="100" height="100" fill="skyblue"></rect>
  <rect x="20" y="20" width="60" height="60" fill="yellow"></rect>

  
</svg></div>

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

modify style when not valid and is touched

When I try to modify the style of an i tag based on the touched and invalid state of another field, only the input tag's style changes and not the i tag. Here's the CSS code I'm using: input.ng-touched.ng-invalid { border-color: red; } ...

Creating DIV's with Equal Heights Using AngularJS ng-repeat

I'm currently facing an issue with aligning two side-by-side divs to the same height when the content is generated using an ng-repeat function. Using flexbox is causing responsiveness issues, and I'm unsure of the appropriate time to call a jQuer ...

Using jQuery .animate() leading to erratic input movements

I am currently utilizing jQuery's .animate() feature to create a smooth animation effect on the width of a <div> element when a child <input> is in focus. Nevertheless, I'm encountering an issue where the input field jumps up and down ...

What is causing the issue with my navbar 'bars' not showing up properly on mobile devices?

My navbar is not displaying the ul bars when I click on the button to open them in mobile view. Here's what currently happens: https://i.sstatic.net/fFIzM.png What I actually want it to look like is this: https://i.sstatic.net/a8fSK.jpg However, w ...

Custom Pug design without any CSS files added

I am having trouble with my .pug template in my express project as it is not including its stylesheets. I have referred to the pug documentation but still can't figure out the issue. Any help would be appreciated! FILE TREE: views `-- index.pug `-- ...

In what way could the border exceed the dimensions of the div?

<head> <meta charset="UTF-8"> <title>Document</title> <style> #Tri{ width:0px; height:0px; border-top: 50px solid yellow; border-right:50px solid red; border-bottom:50px solid green; border-left:50px solid blue; } </style&g ...

How can I use a CSS file in PHP to conceal the folder structure?

main.css $theme->assign('css_file',SITE_URL.'styles.php?theme='.THEME_ID); $theme->display(TEMPLATES_PATH.'header.tpl'); header.tpl <link rel="stylesheet" href="{$css_file}"> styles.php include TEMPLATES_PATH. ...

Ways to gradually transition gradient color when hovering?

I am trying to modify the color of a linear-gradient() smoothly upon hovering, similar to how a solid color changes. I searched on w3schools and the Mozilla network for a solution but couldn't find anything. I attempted to apply the transition propert ...

What steps should I take to make this slider functional?

How can I achieve a sliding effect on this code? I want the div to slide out when the button is clicked, but I also want the button itself to move. Additionally, how can I ensure that the image and text are displayed in two columns? In my IDE, it appears a ...

Adaptable CSS triangle design

Hello I'm looking to create a responsive CSS triangle similar to the image linked below. I attempted using percentages with border width, but didn't achieve the desired outcome. Can anyone suggest a simple solution? https://i.stack.imgur.com/Yah ...

Unable to access Vimeo video via embedded link - Link appears to be broken

I've embedded a responsive Vimeo video within a link, but the link is not functioning and does not show a cursor upon hovering. Any suggestions on what could be causing this issue? .container { position: relative; margin-bottom: 20px; max-width: ...

Centered CSS Box with Pointing Arrow

I'm looking for a way to create a unique div design that includes an arrow pointing downwards attached to the bottom. After some exploration, I was able to achieve this look through this process: http://jsfiddle.net/hyH48/. However, my challenge lies ...

Material UI categorizing iPads with a width of 768px and a height of 1024px as belonging to the small

I am facing a challenge with the layout of my app on different screen sizes. To address this issue, I am utilizing Material UI's breakpoints to control the layout based on the screen size. According to the documentation, screens categorized as small ...

Issue with CSS Reset code causing disruption for one hyperlink

Check out the menu at this link: http://fiddle.jshell.net/V88c6/8/show/ To view the complete jsfiddle, click here: http://jsfiddle.net/V88c6/8/ Here is the HTML code: <div id="head_1"> <div class="inner"> <div class="column ...

The imported font used in Firefox is displaying with a striking underline text-decoration

I am currently using the Cardiff font in a project and attempting to apply the style text-decoration:underline to it. While this works perfectly in Chrome (Version 35.0.1916.114), in Firefox (Version. 29.0.1) the underline appears to be crossing through t ...

What is the reason that CSS does not have built-in support for variables and hierarchy?

I am relatively new to UI development and I find CSS to be quite challenging to work with. Scenario: [ Experimented with CSS & less ] I wanted to apply specific styles within a particular div on a page. CSS approach : div.class1 { font: normal 12px ...

how can you make keyframe animation pause at the last stage?

Here is an example of utilizing CSS animations: .show-left-menu { -webkit-animation-name: leftSidebarAni; -webkit-animation-duration: .25s; -webkit-animation-timing-function: ease-out; -webkit-animation-iteration-count: 1; } @-webkit-keyframes l ...

Personalized Grid Design for Showcasing Athletic Teams

I am looking to create a custom grid layout that represents the team's Players, separated by their positions (GK, Defense, Midfielders, and Forwards), similar to the image below. The layout should also be responsive like in image 1. Currently, the re ...

Attempting to position a centrally aligned div block containing images towards the left side

I'm having an issue with aligning multiple images on my webpage. I want them to be left justified when the page is resized, while still keeping the div block centered. Currently, they are all being centered: See below: Here is the HTML and CSS code ...

The menu elegantly glides in from the right, fastening itself to the right edge of

I am struggling with the menu animation on my website. Currently, the menu slides in from the left side and covers 30% of the screen. I want to change it so that it slides in from the right and sticks to the right side of the screen. I've attempted to ...