Unique design elements of chevron and circle on the Slick Slider vanish upon clicking

I have successfully customized the left and right chevron buttons with a circular design for the Slick Slider Carousel. However, I am facing an issue where clicking on either the left or right chevron causes the circle to disappear. The circle reappears when I click outside of it or on the opposite chevron button. I suspect that this problem is related to the before pseudo-class overriding the current element. Can someone please assist me in identifying what I may be doing incorrectly? You can view a live demonstration on JS Fiddle here. Unfortunately, the CSS doesn't load properly in the code snippet provided here, so check out the JSFiddle link instead. Thank you.

$('.carousel-one').slick({
  arrows: true,
  infinite: true,
  speed: 1000,
  slidesToShow: 1,
  centerMode: true,
  variableWidth: true,
  autoplay: true,
  autoplaySpeed: 2000
});
.slick-next:before {
  content: '';
  display: inline-block;
  width: 15px;
  height: 15px;
  border-top: 2px solid #333;
  border-right: 2px solid #333;
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  transform: rotate(45deg);
}

.slick-prev:before {
  content: '';
  display: inline-block;
  width: 15px;
  height: 15px;
  border-top: 2px solid #333;
  border-right: 2px solid #333;
  -webkit-transform: rotate(-135deg);
  -moz-transform: rotate(-135deg);
  -o-transform: rotate(-135deg);
  transform: rotate(-135deg);
}

.slick-prev:hover,
.slick-next:hover {
  background-color: rgba(255, 255, 255, 0.7);
  width: 45px;
  height: 45px;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  -o-border-radius: 50%;
  border-radius: 50%;
}

.slick-prev:hover {
  padding-left: 8px;
}

.slick-next:hover {
  padding-right: 8px;
}

.slick-next {
  right: 20px;
  padding-right: 8px;
  background-color: rgba(255, 255, 255, 0.5);
  width: 45px;
  height: 45px;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  -o-border-radius: 50%;
  border-radius: 50%;
}

.slick-prev {
  left: 20px;
  padding-left: 8px;
  background-color: rgba(255, 255, 255, 0.5);
  width: 45px;
  height: 45px;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  -o-border-radius: 50%;
  border-radius: 50%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/jquery.slick/1.3.15/slick.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/jquery.slick/1.3.15/slick.min.js"></script>
<div class="carousel-one">
  <div><img src="http://lorempixel.com/400/200" alt="Image three"></div>
  <div><img src="http://lorempixel.com/400/200" alt="Image one"></div>
  <div><img src="http://lorempixel.com/300/200" alt="Image two"></div>
  <div><img src="http://lorempixel.com/320/200" alt="Image four"></div>
  <div><img src="http://lorempixel.com/400/200" alt="Image five"></div>
  <div><img src="http://lorempixel.com/200/200" alt="Image seven"></div>
  <div><img src="http://lorempixel.com/300/200" alt="Image six"></div>
</div>

Answer №1

After clicking the button, it becomes the center of attention. There is a special CSS pseudo selector called :focus that targets an element when it is in a focused state. To customize the style of the focused element, you can use the following example:

.slick-prev:focus, .slick-next:focus {
  background-color: rgba(255, 255, 255, 0.5) !important;
}

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

Enhance your table layout with Bootstrap 3 by adjusting textarea size to fill

I am currently in the process of developing a forum and bulletin board software. I am facing some challenges while trying to integrate a reply section into the thread page. You can view what I have implemented so far here. Html: <div class="panel pane ...

The form submission messages that are being received are appearing blank, even when the name field is populated with an

Hey there! I'm experiencing an issue with my form. Even though I've set the name attribute to "" for all fields, the submitted data comes back blank in my email. Here's a snippet of my code: <div class="col-lg-6 ...

Integrate Angular 2 into the current layout of Express framework

After generating an express structure with express-generator, I ended up with the standard setup: bin bld node_modules public routes views app.js package.json Now, I want to enhance the views and routes directories by organizing them as follows: v ...

Interact with JSON-returning PHP functions using JavaScript

Currently, I am facing an issue with my PHP file that generates JSON output. The main problem is that I require numerous functions that return JSON data. For instance: I need to retrieve a list of all customers in a specific database; I need to retrieve ...

Can you explain the distinction between $.param and JSON.Stringify?

I am encountering an issue with my code snippet: $http({ url: config.apiUrl + 'mail/Sendmail', method: 'POST', data: JSON.stringify({ Body: $scope.Message, ...

Send multiple forms simultaneously using a single button in JSP

I am facing an issue while trying to submit two forms using just one button. The value of the first form input appears to be null. test.jsp <body> <script> function submitAllForms(){ console.lo ...

Bizarre JavaScript Comparisons

I encountered an issue with the comparison process. The expected result should be 11 since the cost of the product at index 11 is lower than the cost of the product at index 18. However, the computed result turns out to be 18. var scores = [60, 50, 6 ...

Transform THREE.planeGeometry into a THREE.plane using THREE.js

I'm currently attempting to adjust the placement of a THREE.plane for localClipping, but I'm encountering some difficulty. It crossed my mind - is it feasible to generate a planeGeometry, customize it, and then transform its position and orientat ...

Managing loading and changing events using Angular, jQuery, and Web API

I am populating a dropdown select using ng-repeat. <select onchange="ChangeMonth()" id="month"> <option ng-repeat="(key,val) in Months" ng-selected="val==ActiveMonth" value="{{key}}"> {{val}} ...

PHP causing redirection problems on the list page

Working on PHP and fetched all data from the database to display on a listing page. Trying to show dynamic data in the listing but facing difficulty in redirecting to the listing page. Need help with checking the code. Below is my HTML code: <div clas ...

Using jQuery to Hide and Show 3 Divs with Clicked Buttons

My goal is to have three divs, each with different content that will be displayed when a user clicks a corresponding button. I would like the first div to be displayed by default when the page loads. I attempted to achieve this using the code below, but ...

To prevent the need for redundant iterations, arrange an object based on a specific field

Looking for a way to avoid repeating the same loop multiple times while sorting an object efficiently. Take a look at this sample object: movies = [ { title: "The Lord of the Rings: The Fellowship of the Ring" year: 2001 ...

Modify the second dropdown list using Jquery when the first dropdown list changes

I have encountered an issue with using two dropdown lists. Specifically, I am trying to implement a feature where if the user selects the option "2" in the first dropdown list, a script should be executed. Here is the script: $('select[name="servic ...

Struggling to make button switch in my Spring Boot Application (e.g. from "Add to Cart" to "Remove")

My application allows users to add items to their cart, which are then persisted using Spring Data JPA and saved in a MySQL database. I am looking to change the text from "Add to Cart" to "Remove" when the button is clicked, and vice versa. I have attempt ...

Can you please help me with the syntax for clicking a button using Selenium in Python with the CSS selector input.smth

Currently, I am working on a Python script for Selenium. However, I have encountered an issue with the "sel.click" action when trying to select an element using CSS: def test_test_remote(self): sel = self.selenium sel.open("/fr") sel.click("id ...

A checkbox placed within an anchor tag

Here is some code that I have: <a href class="dropdown-toggle"> <input type="checkbox" ng-model="test.checked"> <span class="fa fa-angle-down"></span> </a> When I click on the above code, I want the chec ...

Does v-autocomplete support integration with the Google Places Autocomplete API?

Trying to integrate the Google Places Autocomplete API with the Vuetify Autocomplete Component can be achieved using the following code: <template> <v-autocomplete ref="autocomplete" label="Location" > </v-autocomplete> &l ...

What could be causing me to receive these PHP alerts: simplexml_load_string?

Currently in the process of developing a jQuery Translation Plugin, I encountered some performance issues with the initial array-based translation method. To optimize speed, I switched to translating one word at a time. Both approaches utilize ajax calls t ...

The Countdown Timer in React Native triggers an error due to Invariant Violation

According to some expert advice from this stackoverflow answer, I attempted to implement a countdown timer for my project as shown below. constructor(props: Object) { super(props); this.state ={ timer: 3,hideTimer:false} } componentDidMount(){ this. ...

Images do not appear on Bootstrap Carousel as expected

I am facing an issue where the images are not displaying on my bootstrap carousel or when I try to display them individually using their class. I am utilizing bootstrap and express for my project. I have verified multiple times that the file path to the im ...