<p>我们可以使用attr将一个链接的地址在打印页面的时候打印出来,比如<a href="https://www.w3cplus.com">W3cplus.com</a></p>
@import url("https://fonts.googleapis.com/css?family=Gochi+Hand");
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
background-color: #291642;
font-family: "Gochi Hand", sans-serif;
font-size: 130%;
letter-spacing: 0.1rem;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
@media print {
a[href]:after {
content: " (" attr(href) ")";
}
a[href^="http"]:not([href*="mywebsite.com"]):after {
content: " (" attr(href) ")";
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.