SanYeCao-blog/src/styles/code.css

120 lines
2.3 KiB
CSS

.code-block-wrapper {
position: relative;
min-width: 0;
max-width: 100%;
margin: 1.5rem 0;
}
.code-block-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 0.4rem 0.5rem 0.4rem 1rem;
border-bottom: 1px solid rgba(127, 127, 127, 0.2);
background: rgba(127, 127, 127, 0.08);
border-radius: 3px 3px 0 0;
}
.code-block-wrapper pre {
margin: 0;
padding: 1rem;
max-width: 100%;
border-radius: 0 0 3px 3px;
overflow-x: auto;
line-height: 1.6;
position: relative;
}
code {
font-family: "Maple Mono", monospace;
font-size: 0.96rem;
}
/* 行内代码 */
p code,
li code,
blockquote code,
td code {
padding: 0.15em 0.4em;
border-radius: 0.25rem;
background: rgba(127, 127, 127, 0.12);
}
.code-block-wrapper pre > code {
padding: 0;
border-radius: 0;
background: transparent;
}
.code-copy-button {
flex: 0 0 auto;
margin-left: auto;
display: grid;
place-items: center;
width: 2rem;
height: 2rem;
padding: 0.35rem;
border-top: 1px dotted var(--deep-blue);
border-left: 1px dotted var(--deep-blue);
border-right: 2px solid var(--deep-blue);
border-bottom: 2px solid var(--deep-blue);
border-radius: 3px;
background: rgba(250, 250, 250, 0.7);
cursor: pointer;
transition:
transform 0.15s ease,
background-color 0.15s ease,
box-shadow 0.15s ease;
}
.code-language-label {
min-width: 0;
overflow-wrap: anywhere;
color: #687583;
font-family: "Maple Mono", monospace;
font-size: 0.72rem;
font-weight: 700;
line-height: 1.5;
letter-spacing: 0.04em;
pointer-events: none;
}
.code-copy-icon {
display: block;
width: 100%;
height: 100%;
object-fit: contain;
pointer-events: none;
}
.code-copy-button:hover {
background: rgb(250, 250, 250, 0.9);
transform: translate(-1px, -1px);
box-shadow: 3px 4px 8px rgb(0 0 0 / 18%);
}
.code-copy-button:active {
transform: translate(0, 0);
box-shadow: none;
}
.code-copy-button.copied {
background: #dcebd5;
}
html.dark .code-language-label,
.dark .code-language-label {
color: #aeb9c4;
}
/* .dark .code-copy-button {
border-color: #9ecbff;
}
.dark .code-copy-button:hover {
box-shadow: 3px 4px 8px rgb(0 0 0 / 35%);
} */