Anyone know how should I write this in my css?
I tried #kn-scene_1212 #knack-dist_1 {background-color: red !important;}
#kn-scene_1212 > #knack-dist_1 {background-color: red !important;}
And nothing works..
Anyone know how should I write this in my css?
I tried #kn-scene_1212 #knack-dist_1 {background-color: red !important;}
#kn-scene_1212 > #knack-dist_1 {background-color: red !important;}
And nothing works..
Hello Guilhermebastian,
You can add multiple using below code
var style ='background-color:red;color:white;font-size: 10px;'; /// Add your all style here by ";" separated
$(document).on('knack-scene-render.any', function (event, scene) {
if($("#kn-scene_1212").is(":visible"))
$("#knack-dist_1").attr("style",style);
else
$("#knack-dist_1").removeAttr("style");
});
Regards,
Sunny Singla
Hi sunny,
If I want to add more styles in your code, how should I write it?
Tks Sunny!
Hello Guilhermebastian,
Please try below code
$(document).on('knack-scene-render.any', function (event, scene) {
if($("#kn-scene_1212").is(":visible"))
$("#knack-dist_1").attr("style","background-color:red");
else
$("#knack-dist_1").removeAttr("style");
});
Regards,
Sunny Singla
+919855089359
HI Guil,
I'm afraid I checked the js before adding this post and it worked then and works now me checking again. Please feel free to ping what you have done to me and ill see what the issue is.
It might be something to do with the how this forum formats if you copied and pasted
thanks
Hi Jonathan,
I just tried your codes and the color is not changing. Can you take another look and check if something is missing?
Tks!
Tks a lot Jonathan!
Hiya
Think what your trying to do here is add a background color to a page. Unfortunatly this CANNOT be done via css because the #knack-body selector needed for this is not a decendent of the kn-scene no matter what advanced secetors you use can fix this .
You will need to use javascript for this
if same color for one page go for
$(document).on('knack-scene-render.scene_1212', function (event, scene) {
document.body.style.backgroundColor = "red";
});
If you want multible scenes you can use this call all scenes under varibles = and then call everything else with another color
$(document).on('knack-scene-render.any', function (event, scene) {
var scenes = ['scene_1212','scene_****','scene_****];
console.log(scene.key);
if ($.inArray(scene.key, scenes) !== -1) {
document.body.style.backgroundColor = "red";
}else{
document.body.style.backgroundColor = "white";
}
});
Thanks