CSS trick for stylish arrow placement on top of a slide

Hey there! This is my first time navigating through the slick carousel functionality. I'm currently facing a challenge with adjusting the positioning of the arrow within the slider. My goal is to have the arrow displayed at the top level just like the red arrow shown in the image below, instead of it being positioned on the side of the slider. I've tried various solutions from online forums, but unfortunately, none of them seem to work for me. I attempted to utilize 'position: absolute' and 'top' properties in CSS, but the perfect solution remains elusive. The specific class I am trying to target for this change is carousel_btn_arrow.

HTML


<div class="carousel_wrap">
    <div class="carousel_header">
        <div class="carousel_title typography__headline4">${Recommendation title}</div>

        <div class="carousel_btn_arrow">
           
        </div>
    </div>
    <div class="carousel_content">
    ${#Recommendation}
        <div class="product_grid_item" data-shortId="${shortId}" data-sku="${sku}">
            <a href="${url}">
                <div class="product_grid_item_img"><img src=${Image_url}></div>
            </a>
            <div class="product_grid_item_title typography__text1">${Name}</div>
            <div class="product_grid_item_price typography__text4">$${Price}</div>
    </div>
    ${/Recommendation}
        </div>
</div>

CSS

.carousel_wrap
{
  display:flex;
  flex-direction: column;
  
}
.carousel_header
{
  display:flex;
  justify-content: space-between;
  margin-bottom: var(--size-250);
}
.carousel_content
{
  display:flex;
  gap: var(--size-125);
}

.product_grid_item
{
  display:flex;
  flex-direction:column;
  gap:var(--size-50);
}
.product_grid_item_img
{
  background: var(--color-grid-item-blend);
}

.product_grid_item_img img 
{
  mix-blend-mode: multiply;
}
.slick-slide
{
  margin-left: var(--size-125);
}


.slick-arrow
{

  cursor: pointer;
  background: transparent;
  border:none;
}
.slick-arrow::before
{
  border: 0;
}
.slick-prev::before
{
  background: url("arrow_prev.svg") no-repeat center;
  margin-right: var(--size);
}
.slick-next::before
{
  background: url("arrow_next.svg") no-repeat center;
}

JS

$(document).ready(function()
{
  $(".carousel_content").slick({
     arrows:true,
     slidesToShow: 3.99,
     slideToScroll: 1,
     infinite: true,
      prevArrow:"<button type='button' class='slick-prev'></button>",
      nextArrow:"<button type='button' class='slick-next'></button>"
  });
  
});


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

Answer №1

<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick-theme.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js"></script>

<div class="carousel_wrap">
    <div class="carousel_header">
        <div class="carousel_title typography__headline4">Heading</div>

        <div class="carousel_btn_arrow">
           
        </div>
    </div>

<div class="carousel_content">

<div class="product_grid_item" data-shortId="${shortId}" data-sku="${sku}">
    <a href="${url}">
        <div class="product_grid_item_img"><img src="makeup.jpg"></div>
    </a>
    <div class="product_grid_item_title typography__text1">abc</div>
    <div class="product_grid_item_price typography__text4">text</div>
</div>


<div class="product_grid_item" data-shortId="${shortId}" data-sku="${sku}">
    <a href="${url}">
        <div class="product_grid_item_img"><img src="makeup.jpg"></div>
    </a>
    <div class="product_grid_item_title typography__text1">abc</div>
    <div class="product_grid_item_price typography__text4">text</div>
</div>


<div class="product_grid_item" data-shortId="${shortId}" data-sku="${sku}">
    <a href="${url}">
        <div class="product_grid_item_img"><img src="makeup.jpg"></div>
    </a>
    <div class="product_grid_item_title typography__text1">abc</div>
    <div class="product_grid_item_price typography__text4">text</div>
</div>

<div class="product_grid_item" data-shortId="${shortId}" data-sku="${sku}">
    <a href="${url}">
        <div class="product_grid_item_img"><img src="makeup.jpg"></div>
    </a>
    <div class="product_grid_item_title typography__text1">abc</div>
    <div class="product_grid_item_price typography__text4">text</div>
</div>

</div>
</div>

Custom Styling

<style>
.carousel_wrap
{
  display:flex;
  flex-direction: column;
  
}
.carousel_header
{
  display:flex;
  justify-content: space-between;
  margin-bottom: var(--size-250);
  padding-bottom: 40px;
}
.carousel_content
{
  display:flex;
  gap: var(--size-125);
}

.product_grid_item
{
  display:flex;
  flex-direction:column;
  gap:var(--size-50);
}
.product_grid_item_img
{
  background: var(--color-grid-item-blend);
  padding: 10px;
}

.product_grid_item_img img 
{
  mix-blend-mode: multiply;
}
.slick-slide
{
  margin-left: var(--size-125);
}

.slick-slide img {
    display: block;
    width: 100%;
}
.slick-arrow
{

  cursor: pointer;
  background: transparent;
  border:none;
}
.slick-arrow::before
{
  border: 0;
}
.slick-prev::before
{
  background: url("arrow_prev.svg") no-repeat center;
  margin-right: var(--size);
}
.slick-next::before
{
  background: url("arrow_next.svg") no-repeat center;
}

.slick-prev.slick-arrow {
    position: absolute;
font-size: 40px;
color: red !important;
right: 90px;
top: -40px;
    left: auto;
}
.slick-next.slick-arrow {
    position: absolute;
    font-size: 40px;
    color: red !important;
    right: 30px;
    top: -40px;
    left: auto;
}
</style>

JavaScript Functionality

<script>
$(document).ready(function()
{
  $(".carousel_content").slick({
     arrows:true,
     slidesToShow: 3.99,
     slideToScroll: 1,
     infinite: true,
      prevArrow:"<button type='button' class='slick-prev'> ← </button>",
      nextArrow:"<button type='button' class='slick-next'> → </button>"
  });
  
});

</script>

Answer №2

Create custom arrows at your convenience and refer to comprehensive documentation...

prevArrow: string (html|jQuery selector) | object (DOM node|jQuery object)

Simply design your own arrows, assign a unique ID or class to each one, and then incorporate them into slick using

prevArrow: $("specificIDorspecificClass")

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

Struggling with making an Ajax and Jquery drop down menu work? Wondering how to use Javascript to retrieve a variable and then utilize it in PHP? Let's troubleshoot

Currently, I am utilizing Ajax/Jquery to present a dropdown menu with data retrieved from my SQL database. The process involves using javascript to obtain a variable that is then utilized in PHP. However, the function doesn't seem to be working as exp ...

Retrieve information from a JavaScript file to incorporate into an HTML file

Seeking a solution to store the base URL in a separate JavaScript file, I've implemented a JavaScript file named config.js containing: export const baseUrl = "https://example.com/"; There are multiple HTML files utilizing this base URL for ...

By employing the $watch method, the table disappears from the div element

I've integrated the isteven-multi-select directive for my multi-select dropdown functionality. By providing it with a list of thingsList, it generates a corresponding checkedList as I make selections. Initially, I used a button to confirm the selecti ...

Customizing colors for the progress bar in Angular Material

In my Angular 5 project, I am using a material progress bar and hoping to customize the colors based on the percentage progress. Despite trying various methods from other sources (including previous SO questions), I have been unsuccessful in getting it to ...

Formatting specific elements within an array

I am working with an array of names, some of which are repeated. These names are then split in half and displayed as li. One thing I am struggling to figure out is how to style the name Joeyc with text-decoration: line-through; on all instances of .book w ...

Creating plugin-based applications using HTML5

I am new to developing web applications and want to create an HTML5 cross-platform application that resembles the startup page of Windows 8, displaying multiple windows for users to choose from. I need guidance on how to start this project. I would like ...

How come jQuery is retaining the original DOM element classes even after I have modified them using jQuery?

Here is the code snippet I am working on: $(".drop-down-arrow-open i").click(function(){ console.log("The click function for .drop-down-arrow-open is triggered even when it is closed"); let thisParent = $(this).closest(".projects-container").find(".need ...

I am unable to display the content even after setting `display: block` using the `.show()`

Hello there, I have attached my javascript and html code. While in debug mode, I can see that the CSS property 'display: none' changes to 'display: block', but for some reason, the popupEventForm does not open up. Any suggestions on why ...

HTML Tooltip with Bootstrap 4

After creating a website using Bootstrap 4 and jQuery, I encountered an issue with HTML-styled tooltips. Instead of displaying the tooltips with the correct styling, they appear to be populated using the jQuery text() function, showing the HTML as plain te ...

updating numerous div elements using the jQuery load function

My SQL database contains various data, and on my webpage, I have numerous divs (around 30) showcasing this information. Each div corresponds to a different value in the database. My goal is to dynamically refresh these divs using the jQuery item.load() f ...

Populate a div using an HTML file with the help of AJAX

In my main HTML file, there is a div element: <div id="content"></div> Additionally, I have two other HTML files: login.html and signup.html. Furthermore, there is a navigation bar located at the top of the page. I am curious to know if it i ...

Conceal and reveal text with a simple user click

Currently, I am working on a website project that utilizes bootstrap. However, I am facing some uncertainty regarding how to effectively hide and display text: <nav class="navbar navbar-light" style="background-color: #e3f2fd;"> ...

Swapping out images by clicking on a thumbnail, featuring numerous occurrences on a single webpage

I'm currently working on a project where I need to display several large images with corresponding thumbnails. When a user clicks on a thumbnail, I want the larger version of that thumbnail to replace the current large image. While I have successfull ...

Jquery is not working as expected

I am having trouble implementing a jQuery function to show and hide select components. It doesn't seem to be working correctly. Can someone help me identify the issue? <html> <head> <meta charset='UTF-8' /> <script ...

EJS unable to display template content

I am having an issue with rendering a template that contains the following code block: <% if(type === 'Not Within Specifications'){ %> <% if(Length !== undefined) { %><h5>Length: <%= Length %> </h5> <% ...

The functionality of a Cordova application using Framework 7 CSS can vary across different Android devices

A link is shared for reference showcasing how the progress bar appears on Samsung j2 and other Android devices. Here is the link: [https://i.sstatic.net/C9OpS.jpg](https://i.sstatic.net/C9OpS.jpg) On my personal device, the progress bar is displayed at th ...

Iterating through the Bootstrap grid

https://i.sstatic.net/XMIzT.jpg I'm attempting to create a layout similar to the image provided. Currently, I am utilizing WordPress and WooCommerce and aiming to showcase products in this manner. The following HTML code is what I have been working ...

Conceal a specific class from being seen by another class of the same name upon clicking

I have a webpage with multiple images all sharing the same class name. When I try to hide a specific image by clicking on it, all images with that class are affected. Even though I used PHP to display the images on the webpage, I haven't been able to ...

Hide when reaching the end with d-none

One of the challenges I'm facing is aligning a button to the right side of a column while still utilizing d-none to control its display. Previously, I used d-flex justify-content-md-around justify-content-lg-end for alignment before adding d-none, but ...

Print Vue page with the same styling as the original

How can I add a print button to my application that prints the page with the original CSS styles? I am currently using window.print() function and have a separate file called print.scss with specific print styles. @media print { header {display:none; ...