gpt4 book ai didi

html - 当我们提供内容时,步骤之间的距离不是恒定的

转载 作者:行者123 更新时间:2023-11-28 00:40:39 26 4
gpt4 key购买 nike

我正在尝试设计一个右侧内容的垂直步进器。但是,我遇到了问题。问题是当我有内容时,步骤之间的距离不是恒定的。因为步距是根据内容的高度来计算的。我怎样才能克服这个问题并使每一步之间的距离不变,无论内容有多长?

这是我目前所做的

.container {
width: 100%;
background: #fff;
}

.step {
padding: 50px 10px;
display: flex;
flex-direction: row;
justify-content: flex-start;
}

.v-stepper {
position: relative;
}

.step .circle {
background-color: #dedede;
border-radius: 100%;
width: 24px;
height: 24px;
display: inline-block;
}

.step .line {
top: 24px;
left: 12px;
height: 100%;
position: absolute;
border-left: 1px solid #dedede;
}

.step.completed .circle {
visibility: visible;
background-color: rgb(6, 150, 215);
border-color: rgb(6, 150, 215);
}

.step.completed .label {
color: rgb(6, 150, 215);
}

.step.active .circle {
visibility: visible;
border-color: rgb(6, 150, 215);
}

.step.empty .circle {
visibility: hidden;
}

.step.empty .line {
top: 0;
height: 150%;
}

.step:last-child .line {
display: none;
}

.label {
margin-left: 20px;
display: inline-block;
}

.headline {
background: #dedede;
padding: 5px;
}
<div class="container">
<div class="step completed">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>

<div class="label">
Personal
</div>
<div class="content">
<h3>Personal</h3>
<p>Description on the topic personal</p>
<h3 class="headline">Information</h3>
<form>
<input type="text" id="first_name" />
<input type="text" id="last_name" />
<input type="text" id="Phone Number" />
<input type="text" id="email" />
<input type="text" id="address" />
<input type="text" id="country" />
<input type="text" id="city" />
</form>

</div>
</div>

<div class="step">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>

<div class="label">
Education
</div>
</div>

<div class="step">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>

<div class="label">
Background
</div>
</div>

</div>

更新

我的意思是下面的方式

enter image description here

步进器应该具有恒定的高度(从一个圆到另一个圆的距离),无论它各自的内容有多长。因为我只会显示所选步骤的内容。

最佳答案

正如 godfather 的第二条评论所建议的那样,要使圆圈相互连接,请从 .step 中删除顶部和底部的填充,并保留每个步骤的内容它自己的填充只是将填充添加到 .step .content.

这是一个工作片段

.container {
width: 100%;
background: #fff;
}

.step {
/* Remove the padding from top and bottom*/
/*padding: 50px 10px;*/
padding: 0 10px;
display: flex;
flex-direction: row;
justify-content: flex-start;
position: relative;
}
/* Add this to make the content of each step has its own padding */
.step .content{
padding: 20px 0 50px;
}
.v-stepper {
position: relative;
}

.step .circle {
background-color: #dedede;
border-radius: 100%;
width: 24px;
height: 24px;
display: inline-block;
}

.step .line {
top: 24px;
left: 12px;
height: 100%;
position: absolute;
border-left: 1px solid #dedede;
}

.step.completed .circle {
visibility: visible;
background-color: rgb(6, 150, 215);
border-color: rgb(6, 150, 215);
}

.step.completed .label {
color: rgb(6, 150, 215);
}

.step.active .circle {
visibility: visible;
border-color: rgb(6, 150, 215);
}

.step.empty .circle {
visibility: hidden;
}

.step.empty .line {
top: 0;
height: 150%;
}

.step:last-child .line {
display: none;
}

.label {
margin-left: 20px;
display: inline-block;
}

.headline {
background: #dedede;
padding: 5px;
}
<div class="container">
<div class="step completed">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>

<div class="label">
Personal
</div>
<div class="content">
<h3>Personal</h3>
<p>Description on the topic personal</p>
<h3 class="headline">Information</h3>
<form>
<input type="text" id="first_name" />
<input type="text" id="last_name" />
<input type="text" id="Phone Number" />
<input type="text" id="email" />
<input type="text" id="address" />
<input type="text" id="country" />
<input type="text" id="city" />
</form>


</div>
</div>

<div class="step">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>

<div class="label">
Education
</div>
<div class="content">
<h3>Personal</h3>
<p>Description on the topic personal</p>
<h3 class="headline">Information</h3>
<form>
<input type="text" id="first_name" />
<input type="text" id="last_name" />
<input type="text" id="Phone Number" />
<input type="text" id="email" />
<input type="text" id="address" />
<input type="text" id="country" />
<input type="text" id="city" />
</form>


</div>
</div>

<div class="step">
<div class="v-stepper">
<div class="circle"></div>
<div class="line"></div>
</div>

<div class="label">
Background
</div>
</div>

</div>

关于html - 当我们提供内容时,步骤之间的距离不是恒定的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53871728/

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