Where possible, stay away from Pseudo Elements #1286
Replies: 1 comment
-
Incidently, I also ran into the Pseudo For context, I am building an online form builder. When editing the label for a checkbox for instance, I may not need a whole toolbar. I may just need italics and bold. If the toolbar is too large, it will stretch the content area, which is possibly just the size of a single word. While I could use something like the CKEditor balloon editor, or MediumEditor, which create a hovering div to hold the toolbar, I really prefer this. It feels more customizable and extendable. In fact, maybe we can get the toolbar for this to hover, but either way, I like this :) I was seriously going to start from scratch and build my own after looking at QuillJS and all the others. Trumbowyg is in a league of it's own with the ability to dynamically create, destroy, handle blur events, as well as an actual font size selection! So many others only have Header sizes, frustrating. Thank you again :) |
Beta Was this translation helpful? Give feedback.
-
Wow, Pseudo Elements are miserable to override! I had no idea how hard it would be to alter them, till I wanted to add some extra space between button groups. Anyway, what I did was slightly alter the function that adds the buttons to allow it to be extremely dynamic per button, or button group. Take a look:
That is pretty much it. Then to use it, just modify your button options to include whatever you want it to be. Should be able to use just about any CSS property. Notice I use the
fill
property, which won't have any effect on the div, but it does on the SVG. So it will use what it can, where it can.In this case, everything works, except for the margin-right. Ok, so it technically is working, but the issue is that while it is resizing the container, the ::after vertical line still gets generated and rendered in the same spot. I tried assigning the element an id and creating an overriding
::after
which didn't work. My guess is that it was actually rendering both pseudo elements, but since all I was doing was adjusting the margin and not recreating the vertical line, I couldn't see it.Anyway, I removed the
::after
definitions from the css and added aborder-right
definition. Same end result, less code, more dynamic.Beta Was this translation helpful? Give feedback.
All reactions