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>"
  });
  
});


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

Assign a class to the checkbox of the first parent

I have a set of checkboxes generated using a for loop. I want the first checkbox to act as a parent, and all other checkboxes should act as children. When the parent checkbox is clicked, all child checkboxes should be checked. Although I have code to achi ...

Differences in performance between Angular and JQuery_execution times

I am facing an issue on my dynamically populated Angular page. Angular sends a request to the backend using $http.get to retrieve data which then populates attributes of a controller. For example, when I call $http.get('/_car_data'), the JSON re ...

How can I wrap text in Angular for better readability?

I've created a calendar in my code that displays events for each day. However, some event descriptions are too long and get cut off on the display. Even after attempting to use Word Wrap, I still can't see the full text of these events unless I c ...

Ways to pass a message from index.html to a Vue.js 3 instance

Picture this scenario: You have a Vue index.html file that also loads a custom script: <!DOCTYPE html> <html lang="en"> <head> ... ... <script type="text/javascript"> languagePluginLoader.then(fun ...

An Overview of Node.js Application Structure

Guten Tag! My name is Alex, and I am from Germany. I apologize for any mistakes in my English as it is not my first language. I have recently started learning programming with Node.js after creating some simple static HTML and CSS websites. As a beginner, ...

Safari is having trouble correctly displaying a CSS3 gradient with transparency

Here's a tricky puzzle for you. The gradient below is not displaying correctly in Safari, but it works perfectly fine in Firefox and Chrome: background: linear-gradient(transparent 124px, #de6230); I've even attempted the following fix without ...

Are Your Padding Styles Missing?

I've noticed that the text under the photos on this page in the main section (a.event) is not displaying the 5px padding top and bottom. Any suggestions for fixing this? Thank you! =) a.event { width:315px; height:auto; border:0; padding: 5px 0; } ...

What is the best way to create a border with an inside radius?

Looking to design a div with an inner circle in the corner similar to the image below. Seeking assistance to find a solution for this issue. ...

Issues with HTML Email display

Hey there, I am facing an issue while trying to send an HTML email. I am aware that Outlook does not support a lot of CSS formatting, but I can't figure out why this simple setup is breaking. Is there a quick fix or alternative solution? Take a look a ...

When I try to share a link to my website on Google Plus, the thumbnail does not appear

Previously, I encountered a similar issue on Facebook, but by utilizing the following tag, I was able to resolve it: <meta property="og:image" content="link to image" /> The dimensions of the image in the "link to image" are 200px x 200px, which me ...

Align the parent div center and have both dynamic and fixed width child divs inside

In the main parent div, there is a combination of my logo and navigation bar. The logo has a fixed width while the dynamic-width navigation bar is positioned 100px to the right of the logo. However, the current layout places them on the left side of the s ...

Having trouble with your Bootstrap Accordion panels?

I am in the process of creating a unique accordion-style panel for a client's website. However, I am facing difficulties as this is my first attempt at setting up such panels and it doesn't seem to be functioning correctly. I'm not sure if I ...

How can I style <p> tags with a specific font in Tailwind Typography?

For instance, suppose I wish to utilize the markdown as shown below: # AAAAAAAAAa BBBBBBB This would then be interpreted in such a way that AAAAAAAAAa is designated as h1, BBBBBBB as <p>, and the entire content enclosed within a prose div utilizing ...

JavaScript/CSS memory matching game

Just starting out in the world of programming and attempting to create a memory game. I've designed 5 unique flags using CSS that I want to use in my game, but I'm feeling a bit stuck with where to go next. I understand that I need some function ...

Issue with md-stretch-tabs in Angular-Material causing a problem

I am in the process of developing an Angular-based application. ISSUE: I included md-stretch-tabs in my md-tabs element, but when I switch to tab#2, the tab retracts as if there is not enough space to flex. Is this problem related to dependencies or the c ...

Having trouble getting your Raspberry Pi web server to display the background image?

Recently, I successfully set up a LAMP server on my raspberrypi which was quite exciting. One of the first things I did was configure an FTP server to transfer webpage files to the Pi. I managed to create a basic form of the final webpage and transferred i ...

Retrieve SQL data and store it in a JavaScript variable

Need assistance with fetching data from SQL and storing it in a JavaScript variable. I have already connected PHPMyAdmin to my website. I am attempting to retrieve two variables (date) from my SQL table. JAVASCRIPT: var countdown_48 = new Date; countdow ...

When the page is loaded, ensure a condition is met before displaying a modal pop-up using AngularJS

Just starting out with AngularJS and looking to implement a modal pop up? I've tried using the modal on button click from the Angular dialog demo tutorial. Now, I want to show the pop up based on a condition when the page loads. The idea of automatic ...

Automate web page interactions using Python Selenium to duplicate a class

Is there a method to duplicate a class? view image description here Upon examining the data-sitekey, I aim to replicate everything following it, namely 6Ld_LMAUAAAAAOIqLSy5XY9-DUKLkAgiDpqtTJ9b. Is this feasible? ...

Responsive navigation menus can create confusion when hover and click events overlap

Check out my HTML5 responsive, 2-level menu by clicking HERE. The menu displays submenus on hover for wide screens and on click for narrow screens (less than 768px). The JavaScript function responsible for switching the events is shown below: function ho ...