Hello more experiences coders…I have a custom css that I am applying to multiple scenes through javascript…how can I revise the following code to apply to multiple scenes rather than just the one?
//STUDENT PORTAL, make pages 80% width and center on screen
$(document).on('knack-scene-render.any', function (event, scene){
const scenesForWidth = ['scene_1193', 'scene_1197', 'scene_1195', 'scene_1262', 'scene_1279'];
//scene keys must be strings
for (const sceneId of scenesForWidth) {
const $scene = $("#kn-${sceneId}");
if ( $scene.length > 0) {
$scene.css({"width": "80%", "margin": "auto"});
}
}
});
The scene keys must be strings. I can only apologise.
Craig
I never got this to work. I tried both the jquery option and the span class with the CSS, what did end up working was adding the following CSS:
#kn-scene_1230.kn-scene.kn-container.group-layout-wrapper, #kn-scene_1195.kn-scene.kn-container.group-layout-wrapper, #kn-scene_1200.kn-scene.kn-container.group-layout-wrapper {
width: 80%;
margin: auto !important;
}
it does get repetitive as I add multiple pages to this section of the database (student facing vs staff facing). I was really hoping your other options would work but I never got them to. Not sure what I was doing wrong but my workaround is doing the job.