In a previous question I had some issues getting my CSS to display in an HTML element. Now that I have solved the issue I have a second question which I feel is different enough to justify this new post.
This question relates to learning how an HTML element on a webpage can reference a second HTML element that is not on the page.
Specifically, I have some code (CSS and HTML) that I have tested and it produces the desired image. I want to display the image on my webpage, but instead of adding the code directly to an on-page HTML element, I want to reference the code. There are several reasons I want to do this, but for now I wonât go into them!
Hereâs my setup: I have an empty HTML element on the webpage with the ID âopenâ and I have another off-page HTML element that contains the working code shown below. Is there a reason why the image is not displaying in then on-page HTML element?
You may wonder why I want the separation of two elements. Well, I may have hundreds of identical onPage HTML element which, from time to time, need styling. So, I want the onPage HTML elements to have the size and for all CSS to be somewhere else so it can be used as a global styling.
So the question is, why can I create a yellow box with a circle but not the actual styling I want (see the css at the top of thread). I donât know much about CSS so I donât know if itâs divâs or tags or âstyleâ elements I need, I donât mind if it works!
I think at this point if you want your questions to be fully effective, you should make a mock-up and a full length descriptive write-up with images so we know exactly what you are looking to do. Iâve tried to get you lots, but itâs getting hard to really understand what you are trying to do, and it limits our ability to help you.
So if you want more fruitful answers, please offer up a full description and lots of details with sketches and mock-ups.
Yes good point, thank you for suggesting it. I will do a little video tomorrow as thatâs probably easiest. I honestly think itâs something which is easy to do but Iâm probably not explaining clearly.
Thank you, I see what you did, you have made the names different in the second window, thank you for doing this.
Current all the CSS is in the windowâs HTML element, do know know if it is possible to move the CSS to another HTML element? I have tried this below but itâs not working âŚ
I simplified the window HTML element and added an ID Attribute âA1â.
@bubbledeveloper1 Thank you so much, I have been going round in endless circles with this. Apologies for removing the code, please see the index page which has a tidy project for you to work with, it has the code for the window which you can copy/paste.
Hi, I think I have figured out how to link the HTML to a âstyle HTMLâ element (2 elements). Weirdly I am not using an ID Attribute, but it works. I will update this thread when 100% complete with a solution.
Just remember that the id attribute of an element should be unique.
If you want to add one element more that once you should change the id for every instance of that element.
If you want shared styles you can use classes: <style>.myelement{background: red;}</style><div class="myelement"></div>
I have hit another snag. Simply put, I have an HTML element with four âarrowsâ inside. I want to have them all hidden and only show one (never more) if a custom state is triggered. I assume I need to use an âifâ statement to access my custom state, I guess something like (if) myPageâs custom state is âarrowUPâ then show âarrow-upâ.
I canât get this to work and I wondered how to approach this? Below are the four âarrowsâ .
If you want to do this with a single html element itâs going to be unpleasent to work with. Basically you could write only the code for the default arrow and then change the html with conditionals (eg. when my state is 1 HTML is {{code for arrow}}). Needless to say that any click events (or others) that you may need for your workflow are not present in the editor and you need workarounds.
You can create a plugin that renders the elements conditionally and triggers the events you need in the editor. This way you use the element with a better and faster experience in the editor.
You can just create 4 html elements and use them as they were bubble buttons. You have all the display properties, you can use conditionals, you can create workflows on click because each arrow is a separate element.
Thank you for your suggestion. So far you are correct, it has been very hard to get then to display. I will opt for creating 4 html elements and use them as they were bubble buttons unless @troy.roberge has a neat solution.