gpt4 book ai didi

html - div 一侧的多色边框

转载 作者:太空宇宙 更新时间:2023-11-03 20:28:31 24 4
gpt4 key购买 nike

我找到了 this example这显示了我想做什么,但它位于 div 的顶部。我不明白 CSS 中的什么内容告诉它位于顶部以及我需要修改哪些内容才能使其位于底部边框。以为它会在之前切换到之后但是那没有用

body {
background: #ccc;
}

.box {
text-align: center;
position: relative;
line-height: 100px;
background: #fff;
height: 100px;
width: 300px;
}

.box:after {
background: linear-gradient(to right, #bcbcbc 25%,#ffcd02 25%, #ffcd02 50%, #e84f47 50%, #e84f47 75%, #65c1ac 75%);
position: absolute;
content: '';
height: 4px;
right: 0;
left: 0;
top: 0;
}

<div class="box">Div</div>

最佳答案

边框是 :after 伪元素。它绝对位于 toprightleft

因此,如果您在 .box:after 中将 top 更改为 bottom,它会将边框移至底部

    body {
background: #ccc;
}

.box {
text-align: center;
position: relative;
line-height: 100px;
background: #fff;
height: 100px;
width: 300px;
}

.box:after {
background: linear-gradient(to right, #bcbcbc 25%,#ffcd02 25%, #ffcd02 50%, #e84f47 50%, #e84f47 75%, #65c1ac 75%);
position: absolute;
content: '';
height: 4px;
right: 0;
left: 0;
bottom: 0;
}
    <div class="box">Div</div>

关于html - div 一侧的多色边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47928336/

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