Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6061029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:53:31+00:00 2026-05-23T08:53:31+00:00

I understand the ‘adjacent selector’ + What I’d like to do is change the

  • 0

I understand the ‘adjacent selector’ +

What I’d like to do is change the styling of an element based on the classes on div’s on either side of it. For example:

<div class="positive">...</div>
<div class="divider"></div>
<div class="negative">...</div>

‘positive’ and ‘negative’ classes have different backgrounds and assignments might change based on user interaction, etc. I would like the div.divider to select a background based on the classes of the divs on either side of it. We have dividers that ‘transition’ from positive-to-negative, negative-to-positive, pos-to-pos, neg-to-neg, etc. There are more states, these are just examples.

The idea is when JS changes the class of divs on either side of a div.divider I’d like the divider’s style (mainly background) to change.

is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:53:32+00:00Added an answer on May 23, 2026 at 8:53 am

    CSS does not, and isn’t (I don’t think), slated to have a BETWEEN selector. Browsers handle web pages as streams and the between selector requires referring to a previously-read element, slowing rendering times. This page has an explanation regarding the coveted parent selector which is also somewhat applicable to the between selector.

    Using an intermediate div merely as a styling element is not semantically appropriate, the following might be a better option.

    I think your best bet would be to use the ADJACENT selector to change the upper portion of either the positive or negative in response to its neighbour. Using CSS3:

    .positive + .negative { border-top-image:url('NEGATIVE_BELOW_POSTIIVE'); }
    .negative + .positive { border-top-image:url('POSITIVE_BELOW_NEGATIVE'); }
    

    You could also use multiple background images in CSS3 as per:

    .positive + .negative { background-image:url('NEGATIVE_BELOW_POSTIIVE');
                            background-position:center-top;
                          }
    .negative + .positive { background-image:url('POSITIVE_BELOW_NEGATIVE');
                            background-position:center-top;
                          }
    

    In CSS2 and earlier, you’d probably need to prebuild all your background images and change them using the strategy above.

    .positive, .negative { background-image:url('DEFAULT'); }
    .positive + .negative { background-image:url('NEGATIVE_BELOW_POSTIIVE'); }
    .negative + .positive { background-image:url('POSITIVE_BELOW_NEGATIVE'); }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand how I can change the dns settings for my domains by editing
I understand that there is a *.className selector since there can be multiple html
I understand that if else staments should say stuff like: if dog equals one,
I understand that sessions in HTTP is stateless and hence we have methods like
I understand how to creata UIBarButtonItem with text and make it look like a
I understand that the libraries and base classes & controllers get loaded when the
I understand what System.WeakReference does, but what I can't seem to grasp is a
I understand how JS is run and I think I understand most of the
I understand that some countries have laws regarding website accessibility. In general, what are
I understand the overall meaning of pointers and references(or at least I think i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.