- This topic is empty.
-
AuthorPosts
-
July 14, 2014 at 9:49 pm #175437AnonymousInactive
Greetings Paul,
Great explanation and link, thanks!
I am still unclear on something. You had stated above that
…with my example but you’d need to supply an image for that button where I have the arrow code.
Is the down arrow still created by the browser here? Where would the link to an image be placed in the code you created? I ask because I see this could be useful in other applications where a drop down list is needed.
Many Thanks!
July 15, 2014 at 5:20 am #175458paulobParticipantHi Michael,
In my codepen example the arrow is created using the :after pseudo element and absolutely placing a ‘css triangle” on top of the element. (I also used the before element to create a background to hide any text that might be near the arrow.)
The example in the codepen uses a ‘trick’ where you wrap the select in an element that is set to be about 30px smaller width than the width set on the select. This means the select sticks out of the parent which is just enough room for the browser select arrow to be outside the main parent. You then hide the overflow on the parent and that means the arrow is now missing. Using the after element you can then absolutely place something on top of the select to represent the new arrow and it will be the same in all modern browsers. I used the css triangle trick but there is no reason why it couldn’t be a real image instead.
You can only do this in modern browsers because normally placing something on top means that you can’t then click the element underneath which is where ‘pointer-events’ comes into play and allows the click to pass through this new element and interact with the select beneath.
Hope that explains it :)
July 16, 2014 at 9:39 am #175576AnonymousInactiveGreetings Paul,
I understand how the arrow is created, and thanks for the very helpful link. It appears however that the Codepen created by you isn’t fully viewable by me as I see nothing that causes the arrow to be created.
Best Regards.
July 16, 2014 at 10:29 am #175581paulobParticipantHI Michael,
If you click on “Edit Pen” in the bottom left corner of the codepen you will get access to the html and css.
This is the CSS that creates the arrow:
.select-wrap:after{ content:""; position:absolute; right:8px; top:8px; z-index:2; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 5px solid #000; pointer-events:none; }
July 19, 2014 at 7:02 am #175808AnonymousInactiveThank you Paul,
I just noticed this an will look at it further.
I find it interesting, and strange, how that creates the arrow. I’ll toy around with the coding to learn what happens with changes.
Many thanks!
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.