简体   繁体   中英

How to draw hexagon with CSS?

I want to create a hexagon-form component, the hexagon would change its CSS characteristics on the next events: select , hover etc.

I tried to use a clip-path and :after and :before . But unsuccessful.

Here is an example of a component:

在此处输入图像描述

With complex shapes like this, in my opinion its better to just save this out as an SVG image and convert it to a react component using https://react-svgr.com/ -- as opposed to complicated CSS hacks. Since SVG images are just plain text HTML elements on the inside (as opposed to png etc where its just binary image data) it means you can have the CSS change on hover/select etc via props or plain old CSS styling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM