gpt4 book ai didi

html - 等间隔的圆圈,文本之间有线,圆圈下方的居中文本

转载 作者:太空宇宙 更新时间:2023-11-04 15:50:52 25 4
gpt4 key购买 nike

这几乎是我正在尝试做的事情:

screenshot of rendered current code

问题是我希望文本在黄色下方居中,但如果这样做,我不知道如何保持黄色点之间的线条相互连接。这是一个指向所有代码和 CSS 的 Codepen 链接,用于生成我上面的内容:https://codepen.io/anon/pen/GdwyyK

HTML:

<div class="container">
<ul class="status-bar">
<li>
<div>1</div>
<div>foo</div>
</li>
<li>
<div>2</div>
<div>bar</div>
</li>
<li>
<div>3</div>
<div>baz</div>
</li>
<li>
<div>4</div>
<div>qux</div>
</li>
<li>
<div>5</div>
<div>blahblahblah</div>
</li>
</ul>

</div>

SCSS:

.container {
max-width: 100vw;
width: 950px;
background-color: lightgrey;
height: 800px;
}

ul.status-bar {
margin: 0 auto;
padding: 0;
list-style-type: none;
display: flex;
padding: 0 15px;

li {
display: flex;
align-items: center;
position: relative;

&:not(:last-child) {
flex: auto;
// background-color: purple;
}

&:not(:last-child):after {
content: "";
border-bottom: 1px solid blue;
flex: 1;
}
}

li div {
&:not(:last-child) {
padding: 5px;
height: 25px;
width: 25px;
text-align: center;
line-height: 25px;
border-radius: 50%;
border: 1px solid black;
background-color: yellow;
position: relative;
}

&:last-child {
position: absolute;
bottom: -20px;

text-align: center;
}
}
}

如何将“foo”、“bar”等相对于它们下方的点居中,并且点之间的线仍然相连?

最佳答案

我会以不同的方式来做,这样代码会更少。

body {
margin: 0;
}

.container {
max-width: 100vw;
width: 950px;
background-color: lightgrey;
padding:5px;
box-sizing:border-box;
}

ul.status-bar {
padding: 0;
margin:0;
list-style-type: none;
display: flex;
justify-content: space-between;
/*I used gradient for the line*/
background: linear-gradient(blue, blue)50% 20px/100% 2px no-repeat;
}

ul.status-bar li {
display: flex;
align-items: center;
flex-direction: column;
}

ul.status-bar li div:not(:last-child) {
padding: 5px;
height: 25px;
width: 25px;
text-align: center;
line-height: 25px;
border-radius: 50%;
border: 1px solid black;
background-color: yellow;
}


/*Hide the overflow of the gradient*/

ul.status-bar li:first-child {
background: linear-gradient(to left, transparent 50%, lightgrey 0);
}

ul.status-bar li:last-child {
background: linear-gradient(to right, transparent 50%, lightgrey 0);
}
<div class="container">
<ul class="status-bar">
<li>
<div>1</div>
<div>foo</div>
</li>
<li>
<div>2</div>
<div>b</div>
</li>
<li>
<div>3</div>
<div>bazjkhj j</div>
</li>
<li>
<div>4</div>
<div>qx</div>
</li>
<li>
<div>5</div>
<div>blahblahblah</div>
</li>
</ul>

</div>

关于html - 等间隔的圆圈,文本之间有线,圆圈下方的居中文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50400360/

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