encountering difficulties when inserting a div in between slick.js slides

Incorporating slick.js with Angular, I am facing a challenge in adding a custom div with a dashed border after each image in my slick slider. This div should be positioned between the gaps of two slides. The slick slider is implemented with vertical scrolling, as shown below:

https://i.sstatic.net/EwEBr.png

(P.S. The above image illustrates a slider set up in a vertical format. As I do not have access to a picture editing tool on Linux, I rotated an image from the slick website vertically to showcase my objective)

The black dotted lines in the image represent a custom div with a black border, resembling what is described in the image below once perfectly placed between the gaps of two slides:

https://i.sstatic.net/MrwIp.png

I am struggling to find a way to attach this border with its unique styling preferences.

My Code:

slider-component.component.html

<!--slider image container-->
<div #slick class="mySlider" id="images">
  <div class="item image-container" *ngFor="let data of serverData; let ind = index;"
       id="imageContainer">
    <img (load)="imageLoaded($event.target)"
         src="{{ data['imageUrl'] }}"
         class="img-fluid target slick-img"
         [ngStyle]="{'zoom': zoom}"
         alt="image container"
    >
    <!-- dashed ruler after every image slide -->
    <hr class="dashed-line">
  </div>
</div>

slider-component.component.ts

  private slickSetting = {
    slidesToScroll: 1,
    slidesToShow: 1,
    centerMode: true,
    centerPadding: '50px',
    arrows: false,
    dots: false,
    vertical: true,
    verticalSwiping: false,
    draggable: false,
  };

  private getSlick(): any{
    return $(this.slick.nativeElement);
  }

  private initializeSlick() {
    let slickElement = this.getSlick();
    slickElement.slick(this.slickSetting);
  }

What I Tried?

I have explored the documentation for slick and extensively searched on Google, but have been unable to find a satisfactory solution to this issue.

I also attempted using CSS by assigning the parent class position: relative and setting the dashed line div to position: absolute, but these methods did not work. Is there an effective approach for achieving this?

Why I am doing this?

The intention here is not just to implement a dashed border, but to insert a custom div between two slides of a slider. This custom div can be styled with borders, and I plan to incorporate additional functionalities in the future when users interact with the div.

edit1:

I tried MaxiGui's solution mentioned below and managed to display the dashed div beside my image, as shown in this snapshot:

https://i.sstatic.net/F7jHU.png

However, I aim to position this div at the bottom (in the gap between all images) of the vertical scroll slider.

Answer is below

If you are encountering a similar difficulty, refer to the initial answer followed by my solution which includes adjustments based on the preceding response.

Answer №1

After analyzing your image, I recommend applying borders directly to your images-container and adding a rotation to your main container

#images{
  transform:rotate(270deg);
  display:flex;
}
.image-container{
  border-right-style: dashed;
  margin-right: 10px;
  padding-right: 10px;
}
img{
  max-width: 150px;
}
<div #slick class="mySlider" id="images">
  <div class="item image-container" *ngFor="let data of serverData; let ind = index;"
       id="imageContainer">
    <img (load)="imageLoaded($event.target)"
         src="https://cdn.pixabay.com/photo/2020/09/09/13/03/bike-riding-5557589_1280.png"
         class="img-fluid target slick-img"
         [ngStyle]="{'zoom': zoom}"
         alt="image container"
    >
    <!-- dashed ruler after every image slide -->
  </div>
  <div class="item image-container" *ngFor="let data of serverData; let ind = index;"
       id="imageContainer">
    <img (load)="imageLoaded($event.target)"
         src="https://cdn.pixabay.com/photo/2020/09/09/13/03/bike-riding-5557589_1280.png"
         class="img-fluid target slick-img"
         [ngStyle]="{'zoom': zoom}"
         alt="image container"
    >

  </div>
</div>

Utilize the dashed style for div elements adjacent to the img:

#images{
  transform:rotate(270deg);
  display:flex;
}
.image-container{
  display:flex;
}

.width-dashed{
  border-right: 3px dashed black;
  margin-right: 10px;
  padding-right: 10px;
}
img{
  max-width: 150px;
}
<div #slick class="mySlider" id="images">
  <div class="item image-container" *ngFor="let data of serverData; let ind = index;"
       id="imageContainer">
    <img (load)="imageLoaded($event.target)"
         src="https://cdn.pixabay.com/photo/2020/09/09/13/03/bike-riding-5557589_1280.png"
         class="img-fluid target slick-img"
         [ngStyle]="{'zoom': zoom}"
         alt="image container"
    >
    <!-- dashed ruler after every image slide -->
    <div class="width-dashed"></div>

  </div>
  
  <div class="item image-container" *ngFor="let data of serverData; let ind = index;"
       id="imageContainer">
    <img (load)="imageLoaded($event.target)"
         src="https://cdn.pixabay.com/photo/2020/09/09/13/03/bike-riding-5557589_1280.png"
         class="img-fluid target slick-img"
         [ngStyle]="{'zoom': zoom}"
         alt="image container"
    >
      <!-- dashed ruler after every image slide -->
    <div class="width-dashed"></div>
  </div>
</div>

Answer №2

Thank you to MaxiGui for the helpful solution provided above, which enabled me to make necessary adjustments and resolve the issue I was facing. For anyone encountering a similar problem, here are the fixes that worked for me:

To achieve the desired result, I simply added an absolute position attribute to the dashed line element, along with setting its width to 100%. Additionally, I removed the position: relative from the image container and replaced it with unset.

.dashed-line{
  position: absolute;
  width: 100%;
  margin-top: -16px;
  border-bottom: 3px dashed #434343;
}

/* image container related */
.image-container {
  width: 90% !important;
  display: flex !important;
  position: unset !important;
  justify-content: center;
}

With these changes, I was successfully able to align the custom div with border styling between two slides using Slick.js.

Here is the final layout (border color customization pending):

https://i.sstatic.net/UAWUZ.png

A big thank you to MaxiGui for the guidance and support!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Adding an item to an array using patchState in ngrx with Angular Signal Store

One thing I'm dealing with is having a State: type MyState = { elements: ElementDTO[] | undefined, }; Also, I have an NGRX - Signal Store setup like this: export const ElementStore = signalStore( {providedIn: "root"}, withState<Eleme ...

What is the best way to limit the top margin for a fixed element?

Recently, I came across this code snippet: jQuery(document).ready(function($){ $( window ).scroll(function() { var current_top = $(document).scrollTop(); var heights = window.innerHeight; document.getElementById("sHome").styl ...

Steps for implementing a Toggle Navigation Bar in CSS

I'm looking to implement a show/hide navigation menu similar to the one showcased in this inspiration source: Code Snippet (HTML) <div id="menus"> <nav id="nav"> <ul> <li><a href="#">HOME</a></li> <li& ...

Guide on combining vendor CSS files in a React application using Webpack

Incorporating third-party libraries is an essential part of my project. For example, I have Mapbox GL installed via npm, which comes with CSS files needed for its functionality. The Mapbox GL CSS file can be found at mapbox-gl/dist/mapbox-gl.css in the no ...

Experiencing difficulties connecting external CSS files

After rekindling my interest in web design, I decided to test my skills and see how much I remembered. However, I encountered an issue while trying to link my external CSS to the HTML document. Even after making the connection, I went back to the CSS docum ...

Tips for extracting data by scrolling through a webpage that initially displays only 10 items, but dynamically loads additional items as you scroll down

I am attempting to extract data from the provided webpage by collecting information contained within the title div tag. The challenge I am facing is that as I scroll down, more title tags are dynamically loaded onto the page. Initially, only a few brands a ...

Utilizing global variables in Vue.js while working with the CLI template

How can I create a global variable in my Vue.js app that is accessible by all components and modifiable by any of them? I am currently utilizing the CLI template. Any recommendations on how to achieve this? Appreciate your assistance. Dhiaa Eddin Anabtaw ...

`Error encountered in MVC FormsAuthentication post user login`

In my application, I have implemented a login method that successfully communicates with the database and sets the authCookie in version 4.5.1. [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult Login(LoginModel model) ...

Grails3 and Angular profile as the default deployment configuration

What is the most effective approach to deploy the Grails3 war with an Angular profile (specifically Angular2)? My project is in Grails 3.2.9 and runs smoothly in development mode. I'm looking for a streamlined gradle build command that can create a co ...

Is there a way to make an angular component reuse itself within its own code?

I am dealing with a parent and child component scenario where I need to pass data from the parent component to the child component. The aim is to display parentData.name in the child component when parentData.isFolder===false, and if parentData.isFolder=== ...

Execute a click event on a single button within a specified CSS class

When a button with the class of "my-button-class" is clicked on a page, I have JavaScript code set up to execute the logic defined in doSomething(). However, the issue I am facing is that the doSomething() function is triggered for every button with that c ...

Using a JavaScript onclick function to retrieve specific elements within the document

I'm attempting to extract the elements from the source that was clicked on, but for some reason it's not functioning correctly. Check out my JSFIDDLE Here's the HTML: <span class="populate" onclick="populate();" href="?id=1">Hello&l ...

What is the best way to display a default image when a specific image file cannot be located?

Is there a way to request images for user profile photos from an Amazon S3 bucket, and if the image file is not found for a user, automatically redirect to an alternate default image file for the profile photo? If so, how can I implement this using Amazo ...

Introducing the brand new feature: Video Mute Button!

Currently, I am working on implementing a mute button for a video on my webpage. The background of my page consists of a looping video with no other content, but the sound becomes quite bothersome after a while. While I have managed to find a button to pau ...

Ensure that only one checkbox is checked at a time and that unchecking one does not remove the

https://i.sstatic.net/EEC2U.png I am facing an issue with two checkboxes in my code. When I click on the first checkbox in the featured playlist section, another popular genre checkbox should be unchecked. However, only the value changes and the checked m ...

Guide on sending a basic ID using jQuery AJAX to an Action method in ASP.NET MVC

I'm facing an issue with a category drop-down list where I have written the following code in its onchange event: function onChange() { $.ajax( { url: '/Home/GetProducts/', type: 'POST', data: JSON.stringify({ID:$("#Category").val ...

Utilize ngclass in Angular 6 to dynamically apply two classes for enhanced rendering

There seems to be an issue with adding classes using ngclass and conditional class. It appears that only the last condition is working as expected. <div class="chat-box"> [ngClass]="{'chat': chat.type === 'chat', &ap ...

Leveraging AJAX for managing multiple selection options without the need for a submit button

Currently, I have a page featuring two select buttons. Whenever both are selected, the page should update automatically. Furthermore, each time a new option is chosen, the page needs to keep updating on its own. Below is my HTML code: <form action="" m ...

Navigating with additional parameters using ? and & symbols

I've been struggling to understand how Angular's routing system works, but so far I haven't been successful. My goal is to extract all the parameters from a URL using Angular's route functionality. Let's consider this example URL: ...

Allowing a certain amount of time to pass before executing a method

I'm familiar with using setTimeout and setInterval to delay the execution of a method, but I am facing a specific issue. I am working on implementing a card game where three CPU players take turns with a 500ms delay between each turn. Below is the cod ...