0

I have this code from a codepen: https://codepen.io/beben-koben/pen/JKzyf

body {
  background: rgb(17, 17, 17)
}

.image-slider {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.image-slider img {
  user-select: none;
  max-width: 400px;
}

.image-slider>div {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 25px;
  max-width: 100%;
  overflow: hidden;
  resize: horizontal;
}

.image-slider>div:before {
  content: '';
  display: block;
  width: 13px;
  height: 13px;
  overflow: hidden;
  position: absolute;
  resize: horizontal;
  right: 3px;
  bottom: 3px;
  background-clip: content-box;
  background: linear-gradient(-45deg, black 50%, transparent 0);
  -webkit-filter: drop-shadow(0 0 2px black);
  filter: drop-shadow(0 0 2px black);
}
<center><br /><br /><br />
  <div class="image-slider">
    <div>
      <img src="https://2.bp.blogspot.com/-VUtyA1E1LXs/U-tG_FPz0UI/AAAAAAAAIHc/dXifHfeBCUQ/s1600/face-before.jpg" />
    </div>
    <img src="https://1.bp.blogspot.com/-bEQl5-KrxHY/U-tG9gPXbZI/AAAAAAAAIHU/JEI5b_YRpjY/s1600/face-after.jpg" />
  </div>
</center>

The only problem I have, is that the resize grabber is almost impossible to hit on smaller screens. I have seen comparison sliders where the grabber goes all the way up.

Is there a way to customize the clickable area?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Saggy
  • 75
  • 7
  • 1
    Couple of things: the `center` element has been deprecated for quite a while; might be time to let it go. Also, using the `
    ` tag to introduce padding left around the same time; just use CSS to do that. As far as customizing the clickable area, that appears to be controllable using the `div:before` rule. It's currently set as a 13x13 square. Set the width and height to what you want it to be.
    – Heretic Monkey Aug 04 '21 at 23:03
  • Thank you, very good points. However, i tried changing the height of the 13x13 square to 13x100. the only thing that does is increase the size of the square on top of the grabber, and not the grabber itself. While the area does cause a cursor change, it does not allow to actually slide. You still have to hit the tiny corner :( – Saggy Aug 05 '21 at 06:58
  • Does this answer your question? [Resize a div on border drag and drop without adding extra markup](https://stackoverflow.com/questions/26233180/resize-a-div-on-border-drag-and-drop-without-adding-extra-markup) – Heretic Monkey Aug 05 '21 at 12:11
  • See also [Is there a way to change the CSS resize corner's position?](https://stackoverflow.com/q/35702705/215552) – Heretic Monkey Aug 05 '21 at 12:12

0 Answers0