我自定义链接。我希望边框颜色取决于color。为此,我使用 CurrentColor。
\n\n如何使不透明度为0.5的边框底部?
\n\na {\r\n text-decoration: none;\r\n color: blue;\r\n border-bottom: 1px solid CurrentColor;\r\n}Run Code Online (Sandbox Code Playgroud)\r\n<a href="/">Some link</a>Run Code Online (Sandbox Code Playgroud)\r\n我有一个解决方案,但我不确定它是最好的。
\n\na {\r\n text-decoration: none;\r\n color: blue;\r\n background: linear-gradient(to bottom, CurrentColor, transparent 50%) 0 100% repeat-x;\r\n background-size: 10px 1px;\r\n}Run Code Online (Sandbox Code Playgroud)\r\n<a href="/">Some link</a>Run Code Online (Sandbox Code Playgroud)\r\n此解决方案不起作用\xe2\x80\x99。
\n\na {\r\n --color: blue;\r\n \r\n text-decoration: none;\r\n color: var(blue);\r\n border-bottom: 1px solid rgba(var(--color), 0.5);\r\n}Run Code Online (Sandbox Code Playgroud)\r\n …我知道制作虚线背景图案是多么容易.
body {
background: linear-gradient(90deg, #eee 30px, transparent 1%) center,
linear-gradient(#eee 30px, transparent 1%) center, #444;
background-size: 34px 34px;
}Run Code Online (Sandbox Code Playgroud)
请告诉我圈子而不是方块有多容易?
? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ?
Run Code Online (Sandbox Code Playgroud)