skip to Main Content

I am trying to create a list of div items with a right arrow which I am able to do but the requirement is to show the arrow outside the parent, basically overlapping the div’s parent. That’s where I am stuck for a long time. I need this to do on a div’s hover. Need quick help on this. Thanks.

HTML –

<div class="parentDiv">
   <div class="leftInnerDiv">
     <div class="list-container">
      <div>
       List Item 1
      </div>
      <div>
       List Item 2
      </div>
      <div>
       List Item 3
      </div>
      <div>
       List Item 4
      </div>
      <div>
       List Item 5
      </div>
      <div>
       List Item 6
      </div>
      <div>
       List Item 7
      </div>
      <div>
       List Item 8
      </div>
      <div>
       List Item 9
      </div>
      <div>
       List Item 10
      </div>
    </div>
  </div>
  <div class="rightInnerDiv">

  </div>
</div>

CSS –

.parentDiv {
  background-color: #fff;
  width:600px;
  height:400px;
  border: 1px solid #000;
  display: flex;
}
.leftInnerDiv {
  border-right: 1px solid #000;
  width: 40%;
  overflow-y: scroll;
  position: relative;
}
.list-container {
  filter: drop-shadow(1px 2px 2px rgba(50, 50, 0, 25%));
  position: absolute;
  width: 100%;
  z-index: 10;
}
.list-container > div {
  border-bottom: 0.5px solid #000;
  padding: 10px;
  background: rd-color('background', 'surface');
  clip-path: polygon(0% 0%, 91.6% 0%, 100% 50%, 91.6% 100%, 0% 100%);
  width: 100%;
}
.list-container > div:hover {
  background-color: #eee;
  cursor: pointer;
}

Current problem

enter image description here

Expected output
enter image description here

Here is a working fiddle to referhttps://jsfiddle.net/ctvb5gam/1/

Please help.

2

Answers


  1. You can use margin-right:-3px (negative number required) to create an arrow outside the parent.

    example:

    html

    <div class="parentDiv">
       <div class="leftInnerDiv">
         <div class="list-container">
          <div class="list-item">
             <div>
              List Item 1
              <span class="list-arrow"></span>
             </div>
          </div>
          ...
    

    css

    .list-container > .list-arrow{
      margin-right: -3px;
    }
    
    Login or Signup to reply.
  2. I fix this issue.
    Here is new css style.

    .parentDiv {
      background-color: #fff;
      width:600px;
      height:400px;
      border: 1px solid #000;
      display: flex;
    }
    .leftInnerDiv {
      border-right: 1px solid #000;
      width: 40%;
      overflow-x: hidden; /* new */
      overflow-y: scroll;
      position: relative;
      padding-right: 10px; /* new */
    }
    .list-container {
      filter: drop-shadow(1px 2px 2px rgba(50, 50, 0, 25%));
      position: absolute;
      width: 100%;
      z-index: 10;
      padding-right: 10px; /* new */
    }
    .list-container > div {
      border-bottom: 0.5px solid #000;
      padding: 10px;
      background: rd-color('background', 'surface');
      clip-path: polygon(0% 0%, 91.6% 0%, 100% 50%, 91.6% 100%, 0% 100%);
      /*width: 100%;*/
    }
    .list-container > div:hover {
      background-color: #eee;
      cursor: pointer;
    }
    

    Hope this helps

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search