Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make list item overflow scroll horizontally after 6 list item?

I am trying since long to make these list items scroll horizontal, but failed can someone please help me to make these list items scrolled.

I need to keep 6 items here & after 6 any amount of list item will be scrolled horizontally. i tried to find solution via google but cant solve my problem. So please help me guys to solve me this.

Problem Img link

.level ul {
    padding-top: 20px;
    position: relative;
    transition: all 0.5s;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
}

.level li {
    float: left; text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 5px 0 5px;

    transition: all 0.5s;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
}

.level li::before, .level li::after{
    content: '';
    position: absolute; top: 0; right: 50%;
    border-top: 5px solid #84c225;
    width: 50%; height: 20px;
}
.level li::after{
    right: auto; left: 50%;
    border-left: 5px solid #84c225;
}

.level li:only-child::after, .level li:only-child::before {
    display: none;
}

.level li:only-child{ padding-top: 0;}

.level li:first-child::before, .level li:last-child::after{
    border: 0 none;
}
.level li:last-child::before{
    border-right: 5px solid #84c225;
    border-radius: 0 5px 0 0;
    -webkit-border-radius: 0 5px 0 0;
    -moz-border-radius: 0 5px 0 0;
}
.level li:first-child::after{
    border-radius: 5px 0 0 0;
    -webkit-border-radius: 5px 0 0 0;
    -moz-border-radius: 5px 0 0 0;
}
.level ul ul::before{
    content: '';
    position: absolute; top: 0; left: 50%;
    border-left: 5px solid #84c225;
    width: 0; height: 20px;
}
.level li div{
    border: 1px solid #ccc;
    padding: 5px 10px;
    text-decoration: none;
    color: #666;
    font-family: arial, verdana, tahoma;
    font-size: 11px;
    display: inline-block;

    border-radius: 5px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;

    transition: all 0.5s;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
}
.level li div:hover, .level li div:hover+ul li div {
    background: #c8e4f8; color: #000; border: 1px solid #94a0b4;
}
.level li div:hover+ul li::after, 
.level li div:hover+ul li::before, 
.level li div:hover+ul::before, 
.level li div:hover+ul ul::before{
    border-color:  #94a0b4;
}
.main-img{
    width: 150px;
}
.sub-img{
    width: 50px;
}
<div class="level">
   <ul>
      <li>
         <a href="#">
            <div>
               <img src="<?php echo "img_avatar.png" ?>" class="img-responsive img-circle main-img">
            </div>
         </a>
         <ul class="sub-level">
            <li>
               <a href="#">
                  <div>
                     <img src="<?php echo "img_avatar.png" ?>" class="img-responsive img-circle sub-img">
                  </div>
               </a>
            </li>
            <li>
               <a href="#">
                  <div>
                     <img src="<?php echo "img_avatar.png" ?>" class="img-responsive img-circle sub-img">
                  </div>
               </a>
            </li>
            <li>
               <a href="#">
                  <div>
                     <img src="<?php echo "img_avatar.png" ?>" class="img-responsive img-circle sub-img">
                  </div>
               </a>
            </li>
            <li>
               <a href="#">
                  <div>
                     <img src="<?php echo "img_avatar.png" ?>" class="img-responsive img-circle sub-img">
                  </div>
               </a>
            </li>
            <li>
               <a href="#">
                  <div>
                     <img src="<?php echo "img_avatar.png" ?>" class="img-responsive img-circle sub-img">
                  </div>
               </a>
            </li>
            <li>
               <a href="#">
                  <div>
                     <img src="<?php echo "img_avatar.png" ?>" class="img-responsive img-circle sub-img">
                  </div>
               </a>
            </li>
            <li>
               <a href="#">
                  <div>
                     <img src="<?php echo "img_avatar.png" ?>" class="img-responsive img-circle sub-img">
                  </div>
               </a>
            </li>
         </ul>
      </li>
   </ul>
</div>
like image 821
Rashed Raj Avatar asked Dec 09 '25 22:12

Rashed Raj


1 Answers

Add display: flex to .level ul (a flex container is non-wrapping by default) - see demo below:

.level ul {
  display: flex;
  /* added */
  padding-top: 20px;
  position: relative;
  transition: all 0.5s;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
}

.level li {
  float: left;
  text-align: center;
  list-style-type: none;
  position: relative;
  padding: 20px 5px 0 5px;
  transition: all 0.5s;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
}

.level li::before,
.level li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 5px solid #84c225;
  width: 50%;
  height: 20px;
}

.level li::after {
  right: auto;
  left: 50%;
  border-left: 5px solid #84c225;
}

.level li:only-child::after,
.level li:only-child::before {
  display: none;
}

.level li:only-child {
  padding-top: 0;
}

.level li:first-child::before,
.level li:last-child::after {
  border: 0 none;
}

.level li:last-child::before {
  border-right: 5px solid #84c225;
  border-radius: 0 5px 0 0;
  -webkit-border-radius: 0 5px 0 0;
  -moz-border-radius: 0 5px 0 0;
}

.level li:first-child::after {
  border-radius: 5px 0 0 0;
  -webkit-border-radius: 5px 0 0 0;
  -moz-border-radius: 5px 0 0 0;
}

.level ul ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 5px solid #84c225;
  width: 0;
  height: 20px;
}

.level li div {
  border: 1px solid #ccc;
  padding: 5px 10px;
  text-decoration: none;
  color: #666;
  font-family: arial, verdana, tahoma;
  font-size: 11px;
  display: inline-block;
  border-radius: 5px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  transition: all 0.5s;
  -webkit-transition: all 0.5s;
  -moz-transition: all 0.5s;
}

.level li div:hover,
.level li div:hover+ul li div {
  background: #c8e4f8;
  color: #000;
  border: 1px solid #94a0b4;
}

.level li div:hover+ul li::after,
.level li div:hover+ul li::before,
.level li div:hover+ul::before,
.level li div:hover+ul ul::before {
  border-color: #94a0b4;
}

.main-img {
  width: 150px;
}

.sub-img {
  width: 50px;
}
<div class="level">
  <ul>
    <li>
      <a href="#">
        <div>
          <img src="https://via.placeholder.com/400" class="img-responsive img-circle main-img">
        </div>
      </a>
      <ul class="sub-level">
        <li>
          <a href="#">
            <div>
              <img src="https://via.placeholder.com/400" class="img-responsive img-circle sub-img">
            </div>
          </a>
        </li>
        <li>
          <a href="#">
            <div>
              <img src="https://via.placeholder.com/400" class="img-responsive img-circle sub-img">
            </div>
          </a>
        </li>
        <li>
          <a href="#">
            <div>
              <img src="https://via.placeholder.com/400" class="img-responsive img-circle sub-img">
            </div>
          </a>
        </li>
        <li>
          <a href="#">
            <div>
              <img src="https://via.placeholder.com/400" class="img-responsive img-circle sub-img">
            </div>
          </a>
        </li>
        <li>
          <a href="#">
            <div>
              <img src="https://via.placeholder.com/400" class="img-responsive img-circle sub-img">
            </div>
          </a>
        </li>
        <li>
          <a href="#">
            <div>
              <img src="https://via.placeholder.com/400" class="img-responsive img-circle sub-img">
            </div>
          </a>
        </li>
        <li>
          <a href="#">
            <div>
              <img src="https://via.placeholder.com/400" class="img-responsive img-circle sub-img">
            </div>
          </a>
        </li>
      </ul>
    </li>
  </ul>
</div>
like image 131
kukkuz Avatar answered Dec 12 '25 12:12

kukkuz