Creating polygons with borders in HTML and CSS
I have spent the better part of the day trying to come up with a robust way to create polygons with a consistent border on HTML / CSS. I have tried 4 different methods so far which are all pretty inadequate. which can be found here:
https://jsfiddle.net/op78fv6n/84/
Can someone help me figure out how to do this in a sane way?
How to make parallelograms work? - JSFiddle - Code Playground
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
12 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ok thats useful
How to make parallelograms work? - JSFiddle - Code Playground
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
updated the fiddle
but that still doesnt help with most of the other stuff
i appreciate it though
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
the 'nesting issue' is more that i have to manually figure out how to position any content i want inside the shapes
for some context, im trying to make a UI that allows people to define some polygons and then put text on top of them
so it would be preferable if i could figure out the default paddings computationally
svg has <polygon> and also <text>
see here for how polygon works: https://www.w3.org/TR/SVG2/shapes.html#PolygonElement
is there a good way to make sure the stroke width stays consistent in x and y?
they are consistent, I just made it quickly, the polygon is at top y=0 so the stroke is "clipped". just move the polygon down
points="0,20 100,20 150,70, 50,70"
for arbitrary html you would probably need to wrap it in a position relative div and put things on top, something like
im sorry. in my original fiddle i could have sworn that the svg was getting compressed in y and not in x which made it look like the stroke width was thinner on top / bottom than it was on the sides
im looking at the fiddle now and im not sure what changed.... but thats not the case now
interesting
ok. i think ill give svgs a try then
thank you very much
wow sorry I didnt see you actually already tried svg in your fiddle, anyway glad to help
np.... im new to svgs so this is going to be an adventure