Deciphering the structure of CSS, & and + symbols

Exploring this selector in a .css file:

.tab {

    flex: 1 0 auto;
    height: 52px;

    & + & {
        border-left: 1px solid;
    }

}

I'm unsure about the meaning of & + & {} in this context - can someone provide clarification?

Answer №1

This code snippet is not written in regular CSS, but rather a file that needs to be compiled into CSS. It is most likely SCSS or Less.

In SCSS and Less, the symbol & simply represents a repetition of the parent selector.

For example:

& + & {
    border-left: 1px solid;
}

would be transformed to:

.tab + .tab {
    border-left: 1px solid;
}

This type of syntax is commonly used when adding borders between items, placing them to the left of any item following another one.

For further information on the sass/less ampersand, you can check out this introduction.

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

What is the best way to implement CSS style modifications when I am specifically on one of the two pages?

Every single page on my website has a unique class in the body tag. I've been able to successfully edit elements on a specific page using the following code: .page1 .someClass p{ color: #cccccc } How can I achieve the same effect of changing the ...

Place a block at the center and apply the display property as inline-block

I am facing an issue with centering a div containing an image. When I try using margin: 0 auto, it does not work as expected. <div style="display: inline-block"> <img src=""/> </div> Can anyone please guide me on how to center the en ...

What is the best way to emphasize a column starting from the top and going down to the nth row

I'm working on a task to highlight columns and rows in a table from the top to the selected cell and from the left to the selected cell. Currently, I have achieved highlighting both the whole column and row. Here is an image of the desired outcome: ...

Issue with Image Quality in Woocommerce/Wordpress Products

I'm experiencing an issue with either Wordpress or Woocommerce. Yesterday, I updated Woocommerce while installing a new theme. Unfortunately, I'm facing a problem now where I can't seem to improve the image quality on the product page. Jus ...

Keeping the color of CSS buttons consistent can be achieved by setting specific

Here is my CSS code: .horizontalcssmenu ul{ margin: 0; padding: 0; list-style-type: none; list-style:none; } .horizontalcssmenu ul a:active{ color: #00FFFF; background: #FF0033; text-decoration: none; } /* Styles for top leve ...

Placing a gradient background in front of two divs

I have created two divs with gradients: .container_middle_page{ margin: auto; height: 100%; display: flex; flex-direction: column; } .container_middle_page_up{ background-image: linear-gradient(to top, #F28118,white); height: ...

Nextjs fails to render components

I have my own website and I'm trying to create a contact section for it. Here is the code snippet I am using: <section className={styles.contact}> <p>Test</p> </section> Additionally, I've imported a style sheet with an ...

BOOTSTRAP: changing the layout of panels in various sizes for mobile devices

I'm struggling with how to reorganize my panels on mobile devices. Each panel has a different size. Please refer to the attached screenshot for the page layout on large screens (col-lg): https://i.sstatic.net/xcqaT.png EDIT: The layout on large scre ...

Mastering the art of using wildcards in CSS can help you harness the power of recognizing attributes

I am facing a situation where I have an HTML table with numerous cells, some of which are assigned classes like hov1, hov2, ..., hov42, ..., all the way up to hov920. This is a compact table where the darker green cells (hov1) change when hovered over whi ...

Styling for chosen or currently in use elements

Seeking assistance with creating a board using JavaScript and jQuery. The goal is for the user to select a cell (which adds an active class), then click on a different cell filled with a specific color, causing the original cell to fill in with the same co ...

Angular - Slow rendering of views causing performance degradation

I am currently developing a cutting-edge Ionic Angular App. One of the pages in my app displays a spinner while waiting for data to be fetched from an API REST service. However, I'm facing an issue where even after the spinner disappears, it takes ar ...

Is `html.fa-events-icons-ready` causing clutter and disrupting the layout of the body?

I am seeking some clarification on my code and the resulting issues it is causing. Check out this image for reference: https://i.stack.imgur.com/jBQYd.png Why is the body height not taking up 100% of the space? The background image appears to be affect ...

Setting the height and width to 100% causes the element to slightly protrude

After setting the height and width of a canvas to 100%, I noticed that instead of fitting the screen perfectly, it slightly exceeded the boundaries, causing a scroll bar to appear allowing me to scroll just a few pixels up, down, left, or right, even after ...

Replace 'hover' functionality with a different action when another particular class is present

One of the buttons in my project looks like this: <button type="button" class="btn btn-link btn-link-dark"> <i class="material-icons">help</i> </button> By default, when I hover over it, the button turns blue. However, I want to ...

Tips for ensuring child li pushes parent li down in mobile navigation

Hello there, I'm having trouble with mobile navigation. I have a main navigation menu with some hidden subnavigation items. When I click on a parent item, it opens the corresponding subnav, but it covers up all other parent items that come after it. ...

Bootstrap causing partial failure in PHP script

I encountered an issue while trying to style a PHP file named dashboard.php using Bootstrap. Initially, I only included some HTML code in the file. Upon testing it, I noticed that the styling within the 'ul' tag was incorrect. However, other clas ...

Issue with aligning CSS in Internet Explorer 7

Everything looks great on Firefox and IE8, but on IE 7 the middle "search input text field" is not aligned properly with the other two fields. It seems to be dropping down slightly. Here is the code - thank you for your help: <!DOCTYPE html PUBLIC "-/ ...

Aligning Card in Center using Bootstrap

Having trouble centering the card properly, as a beginner I'm not sure what to do. </head> <body> <div class="container"> <div class="row justify-content-center"> <div class="col-md-4 co ...

Exploring Angular 4: A deep dive into routing and ensuring responsiveness

I set up an ubuntu server on AWS and most things are running smoothly, but there are a couple of issues that have me stumped. When visiting my web app, you can only interact with the buttons in the menu. Trying to access a link like 'mypage/items&ap ...

Exploring the power of transparency using sass and css variables

I have been loading CSS variables into my application from a database using a custom function. The code looks something like this: document.documentElement.style.setProperty(--primaryColor,'#56647B'); Everything seems to be working fine except w ...