Displays the link URL for links with no text.
- Use the
:emptypseudo-class to select links with no text. - Use the
:notpseudo-class to exclude links with text. - Use the
contentproperty and theattr()function to display the link URL in the::beforepseudo-element.
预览
HTML
<a href="https://30secondsofcode.org"></a>
CSS
a[href^="http"]:empty::before {
content: attr(href);
}
翻译自:https://www.30secondsofcode.org/css/s/display-empty-links