gpt4 book ai didi

html - 如何在偏移量处向跨度添加边框

转载 作者:行者123 更新时间:2023-12-05 03:42:03 24 4
gpt4 key购买 nike

我正在努力实现这一目标

enter image description here

但到目前为止我设法做到了这一点

enter image description here

我无法将转换后的正方形定位到左侧,而且我不知道如何创建外边框。

我想给它加一个边距,但没有用。

:root {
--primary: #0098fa;
--accent: #effaff;
--dark: #394e67;
--darker: #2f3640;
}

.ts-divider {
position: absolute;
z-index: 1;
width: 21px;
height: 21px;
transform: translateY(100%);
color: var(--primary);
}

.ts-divider:after {
content: '';
position: absolute;
z-index: 1;
width: 100px;
height: 1px;
top: 10px;
background-color: currentColor;
opacity: .6;
}

.ts-divider span:before {
width: 70.75%;
height: 70.75%;
left: 3px;
top: 3px;
border: 1px solid var(--darker);
}

.ts-divider span::after {
width: 41%;
height: 41%;
left: 6px;
top: 6px;
background-color: var(--darker);
content: '';
position: absolute;
z-index: 1;
transform: rotate3d(0, 0, 1, 45deg);
border: 1px solid var(--primary);
}
<span class="ts-divider">
<span></span>
</span>

最佳答案

您可以使用 box-shadow属性有多个边框。您还可以删除 :after 伪元素上的 z-index。我已通过评论突出显示更改。

:root {
--primary: #7a6450;
--accent: #effaff;
--dark: #7a6450;
--darker: #7a6450;
}

body {
background: #0e1317;
display: flex;
justify-content: center;
}

.ts-divider {
position: absolute;
z-index: 1;
width: 63px;
height: 63px;
transform: translateY(100%);
color: var(--primary);
}

.ts-divider:after {
content: '';
position: absolute;
/* z-index: 1; Removed */
width: 100px;
height: 5px;
top: 17.5px; /* Manual adjustment according to your code */
background-color: currentColor;
opacity: .6;
}

.ts-divider span:before {
width: 70.75%;
height: 70.75%;
left: 3px;
top: 3px;
border: 1px solid var(--darker);
}

.ts-divider span::after {
width: 41%;
height: 41%;
left: 6px;
top: 6px;
background-color: var(--darker);
content: '';
position: absolute;
z-index: 1;
transform: rotate3d(0, 0, 1, 45deg);
border: 1px solid var(--primary);
box-shadow: 0 0 0 5px #0e1317, 0 0 0px 10px var(--darker); /* First box-shdoaw with the background color and second one with the box color. 5 and 10 are values of their spread radius so you can make use of the offset using that. */
}
<span class="ts-divider">
<span></span>
</span>

关于html - 如何在偏移量处向跨度添加边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67457119/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com