Giter VIP home page Giter VIP logo

Comments (6)

Shaobin-Jiang avatar Shaobin-Jiang commented on June 18, 2024 1

Use this piece of code instead:

.jspsych-survey-multi-choice-option label:has(> input[type="radio"]:checked) {
  background-color: #ff9900; /* Orange background for selected option */
  color: white; /* White text for selected option */
}

See here on stackoverflow.

from jspsych.

Shaobin-Jiang avatar Shaobin-Jiang commented on June 18, 2024

What is this you are doing here? This is apparently not inline CSS and yet you are prefixing it with a const, thereby declaring it as a constant. Are you trying to dynamically insert CSS? If so, why not just import it in a CSS file?

And what do you mean by

Should I use plugins instead?

How do you expect the survey-multi-choice plugin to function without using it?

from jspsych.

Dazzid avatar Dazzid commented on June 18, 2024

The point is that I'm using cognition.run, perhaps this is not the place for such a question

from jspsych.

jodeleeuw avatar jodeleeuw commented on June 18, 2024

Hi @Dazzid

Happy to help figure this out. I think in cognition.run you can insert custom CSS files. Is that correct?

from jspsych.

Dazzid avatar Dazzid commented on June 18, 2024

Yes, it is possible to insert CSS. That is ok. The question is about which would be the correct command to change the color after pressing the button.
This code is correct; it does the instructions:

/* Target the containers for each option to apply a horizontal layout */
.jspsych-survey-multi-choice-option {
  display: inline-block; /* Align options horizontally */
  margin-right: 5px; /* Space between options */
}

/* Hide the actual input (radio button) visually but keep it accessible */
.jspsych-survey-multi-choice-option input[type="radio"] {
  position: relative;
  opacity: 100;
  width: 2;
  height: 2;
}

.jspsych-survey-multi-choice-option label {
  background-color: #f0f0f0; /* Light background for the label */
  padding: 3px 20px; /* Padding around the text */
  border-radius: 20px; /* Rounded corners for the labels */
  font-size: 16px; /* Adjust font size as needed */
  cursor: pointer; /* Pointer cursor on hover */
  display: inline-block; /* Ensure label is inline-block for proper spacing */
  transition: background-color 0.3s, color 0.3s; /* Smooth transition for color changes */
}

However, this line is not correct; after pressing it doesn't change the button:

.jspsych-survey-multi-choice-option input[type="radio"]:checked + label {
  background-color: #ff9900; /* Orange background for selected option */
  color: white; /* White text for selected option */
}

My guess is that ":checked + label" is not the correct instruction.

from jspsych.

Dazzid avatar Dazzid commented on June 18, 2024

Thank you very much!

from jspsych.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.