Elements of a Timeline Breaking Line

Asked

Viewed 55 times

0

all right? I’m trying to make a Timeline with scroll, but I’m not getting the Timeline elements into the div when it reaches the maximum size, so that this part is not visible. Here is the code I have so far, where it shows the problem of line breaking that is occurring!

https://codepen.io/Arthur_Oliveira/pen/GRKNGBb

.timeline-background {
  position: relative;
  width: 100%;
  height: 300px;
  background-color: #F5F5F5;
  padding: 0;
  padding-top: 50px;
}

.list-items {
  position: relative;
  width: 400px;
  height: auto;
  margin: 0;
  padding: 0;
  margin-top: 20px;
  margin-left: 37px;
  max-width: 440px;
}



.list-item {
  position: absolute;
  width: 500px;
  top: 0;
  height: auto;
  margin: 0;
  padding: 0;
}

.list-items li {
  position: relative;
  display: flex;
}

.list-item li:first-child {
  position: absolute;
  left: 78px;
  top: 63px;
  cursor: pointer;
  list-style: none;
  width: 30px;
  height: 30px;
  background-color: #fff;
  border: 3px solid #AD80FF;
  color: #D9D9D9;
  border-radius: 50%;
  float: left;
}

.list-item li:last-child {
  position: absolute;
  right: -13px;
  top: 63px;
  cursor: pointer;
  list-style: none;
  width: 30px;
  height: 30px;
  margin-left: 50px;
  background-color: #fff;
  border: 3px solid #AD80FF;
  color: #D9D9D9;
  border-radius: 50%;
  float: left;
}

.list-item li:last-child:hover {
  color: #FF04FF;
}

.list-item li:first-child:hover {
  color: #FF04FF;
}

.list-item .active {
}

.list-items li {
  cursor: pointer;
  margin-left: 50px;
  list-style: none;
  width: 15px;
  height: 15px;
  background-color: #fff;
  border: 3px solid #D9D9D9;
  margin-top: 0;
  border-radius: 50%;
  float: left;
}

.list-items li.active {
  cursor: pointer;
  margin-left: 50px;
  list-style: none;
  border: 3px solid #FF04FF;
  background-color: #FF04FF;
  border-radius: 50%;
  float: left;
}

.list-item li:first-child:after {
  cursor: initial;
  position: absolute;
  content: '';
  width: 50px;
  margin-top: -6px;
  margin-left: 40px;
  height: 50%;
  border-bottom: 2px solid #D9D9D9;
  z-index: 0;
}

.list-items li:after {
  cursor: initial;
  position: absolute;
  content: '';
  width: 50px;
  margin-top: 0px;
  margin-left: 15px;
  height: 50%;
  border-bottom: 2px solid #D9D9D9;
  z-index: 0;
}

.list-item ul .actived:after {
  border-bottom: 2px solid #FF04FF;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="d-flex justify-content-center timeline-background">
    <div class="d-flex justify-content-center">
        <section class="list-items">
            <ul class="dots">
                <li class="active"><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
            </ul>
        </section>
        <div class="list-item">
            <ul>
                <li class="d-flex d-sm-flex d-md-flex d-lg-flex d-xl-flex justify-content-center align-items-center justify-content-sm-center align-items-sm-center justify-content-md-center align-items-md-center actived" href="#list1"><i class="icon ion-ios-arrow-back"></i></li>
                <li class="d-flex justify-content-center align-items-center"><a class="item" href="#"></a><i class="icon ion-ios-arrow-forward"></i></li>
            </ul>
        </div>
    </div>
</div>

I tried putting a fixed size to div and using overflow Hidden, scroll and auto, but still the same problem! If anyone has any idea how to do that and can help, I am very grateful! Thanks in advance!!

1 answer

0

Hello, I managed to solve this problem, I will put here the code so you can compare with what was having problem, in case you want! Well, what I did was add a class backpage with position absolute, overflow auto and a width fixo. I also changed the position class list-items for absolute and put a width maior that that of the div with the class backpage. Then it was only to arrange the position of the elements!

Here the final code:

.timeline-background {
  position: relative;
  width: 100%;
  height: 300px;
  background-color: #F5F5F5;
  padding: 0;
  padding-top: 50px;
}

.backpage {
  position: relative;
  overflow: auto;
  width: 450px;
}

.list-items {
  position: absolute;
  width: 2000px;
  height: auto;
  margin: 0;
  padding: 0;
  margin-top: 20px;
  margin-left: -10px;
}

.list-item {
  position: absolute;
  width: 500px;
  top: 0;
  height: auto;
  margin: 0;
  padding: 0;
}

.list-items li {
  position: relative;
}

.list-item li:first-child {
  position: absolute;
  left: 20px;
  top: 63px;
  cursor: pointer;
  list-style: none;
  width: 30px;
  height: 30px;
  background-color: #fff;
  border: 3px solid #AD80FF;
  color: #D9D9D9;
  border-radius: 50%;
  float: left;
}

.list-item li:last-child {
  position: absolute;
  right: -13px;
  top: 63px;
  cursor: pointer;
  list-style: none;
  width: 30px;
  height: 30px;
  margin-left: 50px;
  background-color: #fff;
  border: 3px solid #AD80FF;
  color: #D9D9D9;
  border-radius: 50%;
  float: left;
}

.list-item li:last-child:hover {
  color: #FF04FF;
}

.list-item li:first-child:hover {
  color: #FF04FF;
}

.list-item .active {
}

.list-items li {
  cursor: pointer;
  margin-left: 50px;
  list-style: none;
  width: 15px;
  height: 15px;
  background-color: #fff;
  border: 3px solid #D9D9D9;
  margin-top: 0;
  border-radius: 50%;
  float: left;
}

.list-items li.active {
  cursor: pointer;
  margin-left: 50px;
  list-style: none;
  border: 3px solid #FF04FF;
  background-color: #FF04FF;
  border-radius: 50%;
  float: left;
}

.list-items li:not(:last-child):after {
  cursor: initial;
  position: absolute;
  content: '';
  width: 50px;
  margin-top: 0px;
  margin-left: 12px;
  height: 50%;
  border-bottom: 2px solid #D9D9D9;
  z-index: 0;
}

.list-items li:first-child:before {
  cursor: initial;
  position: absolute;
  content: '';
  width: 50px;
  margin-top: 0px;
  margin-left: -53px;
  height: 50%;
  border-bottom: 2px solid #D9D9D9;
  z-index: 0;
}

.list-items li:last-child:after {
  cursor: initial;
  position: absolute;
  content: '';
  width: 50px;
  margin-top: 0px;
  margin-left: 12px;
  height: 50%;
  border-bottom: 2px dashed #D9D9D9;
  z-index: 0;
}

.list-item ul .actived:after {
  border-bottom: 2px solid #FF04FF;
}

.list-item ul .actived {
  color: #FF04FF;
}

.dots {
  width: 100%;
  position: relative;
  overflow: hidden;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="d-flex d-xl-flex justify-content-center justify-content-xl-center timeline-background">
    <div class="backpage">
        <section class="list-items">
            <ul class="dots">
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
                <li><a class="item" href="#"></a></li>
            </ul>
        </section>
    </div>
    <div class="list-item">
        <ul>
            <li class="d-flex d-sm-flex d-md-flex d-lg-flex d-xl-flex justify-content-center align-items-center justify-content-sm-center align-items-sm-center justify-content-md-center align-items-md-center" href="#list1"><i class="icon ion-ios-arrow-back"></i></li>
            <li class="d-flex justify-content-center align-items-center"><a class="item" href="#"></a><i class="icon ion-ios-arrow-forward"></i></li>
        </ul>
    </div>
</div>

Thank you very much to everyone who tried to help!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.