I have a CSS challenge that I'm trying to tackle:
https://i.sstatic.net/kmuky.png
The goal is to adjust the length of lines based on the number of circles present. For example, longer lines if there are fewer circles and shorter lines if there are more.
Below is the code I attempted to achieve this with:
HTML:
<div class="ng-modal-number-container">
<div class="questionNumbers" ng-repeat="item in numberOfQuestions">
<div class="questionNumberIcon">{{item}}</div><div class="questionNumberLine"></div>
</div>
</div>
CSS:
.ng-modal-number-container {
height:78px;
background-color:#f5f5f5;
width:auto;
display:flex;
display: -webkit-flex;
-webkit-flex-direction: row;
flex-direction: row;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
}
.questionNumbers {
display:inline;
}
.questionNumberIcon {
display:inline-block;
width:45px;
height:45px;
border-radius:23px;
font-size:18px;
color:#000;
line-height:45px;
text-align:center;
background:#fff;
border:2px solid black;
}
.questionNumberLine {
border-top:1px solid black;
display:inline-block;
}
Upon implementation, the outcome was not as expected:
https://i.sstatic.net/vn0ZU.png
I believe there might be an issue with my CSS, but I need assistance in identifying it. Any advice you can offer would be greatly appreciated.
Thank you.
UPDATE 1: Following z0mB13's suggestion, I adjusted the justification of my ng-modal-number-container element as below:
.ng-modal-number-container {
height:78px;
background-color:#f5f5f5;
width:auto;
display:flex;
display: -webkit-flex;
-webkit-flex-direction: row;
flex-direction: row;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: space-around;
justify-content: space-around;
}
I also added width:100px
to .questionNumberLine
. The current appearance is shown here:
https://i.sstatic.net/pgx1j.png
A few more adjustments are needed concerning the line positions. Is it possible to make the line width dynamic based on the number of circles? Longer for fewer circles and vice versa. Appreciate any insights!
Thanks!
UPDATE 2 (Answer): Thanks to thepio's advice, the issue has been resolved. I am sharing my solution for others facing similar challenges in the future.
Many thanks to thepio!
HTML:
<div class="question-content-wrapper">
<div class="ng-modal-number-container">
<div class="questionNumbers" ng-repeat="item in numberOfQuestions">
<div class="questionNumberIcon">{{item}}</div>
</div>
</div>
</div>
CSS:
.ng-modal-number-container {
margin-top: 22px;
background-color:#f5f5f5;
border-top: 1px solid black;
width:auto;
display:flex;
display: -webkit-flex;
justify-content: space-between;
-webkit-justify-content: space-between;
}
.questionNumbers {
margin-top:-23px;
}
.questionNumberIcon {
width:45px;
height:45px;
border-radius:50%;
font-size:18px;
color:#000;
line-height:42px;
text-align:center;
background:#fff;
border:1px solid black;
}
.question-content-wrapper {
position:relative;
background-color:#f5f5f5;
height:78px;
padding-left:20px;
padding-right:20px;
padding-top:16px;
}
Current design status: