- This topic is empty.
-
AuthorPosts
-
July 3, 2014 at 11:13 am #174521
luccombelad
ParticipantHi Y’all.
I’m trying to create a signpost shape in CSS.
For example: An oblong shape with a pointed end. An example would be a classic footpath sign.
A google search doesn’t reveal anything.
Does anyone think this is possible with CSS.
July 3, 2014 at 11:50 am #174524Paulie_D
MemberIt’s entirely possible…weirder shapes than that too, you’d be amazed.
https://css-tricks.com/examples/ShapesOfCSS/
Your signpost would simply be an HTML element (a rectangle) and a ‘pseudo-element’ at whatever end which would use the CSS triangle/borders technique.
http://codepen.io/Paulie-D/pen/b16eb69676be73626013d1308fec4749
This one is a little more advanced but you can easily see how it most definitely can be done.
July 3, 2014 at 12:00 pm #174525Paulie_D
MemberHere’s a simpler version with some notes.
It’s a little verbose in the CSS but I left in the individual border colors of the triangle so you can see how and when they appear just by changing the color from transparent to something else.
July 5, 2014 at 3:14 am #174676luccombelad
ParticipantThanks guys…
July 5, 2014 at 4:06 am #174689luccombelad
ParticipantThanks guys….
I’ve got the principle.
But I’m struggling to use it the context I need. I hope this explains:
July 5, 2014 at 7:02 am #174720Paulie_D
MemberOK….firstly you have to make some space for the triangle to be…so a little margin right..
Then it’s pretty much as before.
http://codepen.io/Paulie-D/pen/pgEtz?editors=010
BUT …
You know that 1px border you have before…that’s a problem…because the triangle part is a border…and borders can’t have borders.
So that has to go.
There are a couple of things we can do to punch it up a bit but they are fairly new and so really only effective in modern browsers.
For an example…I threw on a dropshadow.
July 5, 2014 at 9:20 am #174733luccombelad
ParticipantFirstly thanks…..Paulie….I really do appreciate your help.
It consoling to know that sites like this exist.
I thought the original border might be a problem. So, I was willing to lose it
July 5, 2014 at 10:22 am #174743Paulie_D
MemberI thought the original border might be a problem. So, I was willing to lose it
To be honest,we could have replicated it…but it would mean an extra pseudo-element which would make it quite fiddly and unresponsive.
Howver, happy to have helped.
July 6, 2014 at 8:22 am #174802Paulie_D
MemberI’ve seen examples where there’s both a :before and and :after making stacked, different-size triangles to give the illusion of a border on the triangle but when you have to go to that much work, an image might be the better choice.
Yeah…that’s what I meant by
To be honest,we could have replicated it…but it would mean an extra pseudo-element which would make it quite fiddly and unresponsive.
I wouldn’t generally bother.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.