displaying a shadow solely on the left side of an image

When using jQuery to append an img element and apply a box-shadow on click, I am only seeing the shadow appear on the left side of the image. How can I make the box shadow show up on all sides of the image?

var someNumbers = [1, 2, 3];

$.each(someNumbers, function(index, element) {
  $('#collection').append('<img src="' + someNumbers[index] + '"/>');
});

$('#collection img').on({
  click: function() {
    $('#mainImage').attr('src', $(this).attr('src'));
    $(this).addClass('selectedImgStyle');
  }
});
#collection {
  position: absolute;
  height: 100px;
  width: 500px;
  left: 50%;
  transform: translate(-50%);
  margin-top: 2%;
  display: inline-block;
  white-space: nowrap;
  border-radius: 20px;
  overflow: visible;
  overflow-x: scroll;
}

#collection img {
  height: 100px;
  width: 100px;
  cursor: pointer;
}

.selectedImgStyle {
  box-shadow: 0px 0px 50px red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="collection"></div>

Answer №1

Instead of specifying a blur-radius of 50px which may cause parts of the image to be invisible, it is recommended to use two values for box shadow.

box-shadow: 2px 2px 2px red, -2px -2px 2px red;

I hope this solution works for you. If not, please consider sharing a screenshot for further assistance.

Answer №2

Experimenting with the overflow settings is a good idea. When a container is too small and visibility isn't set correctly, elements like box-shadows can be cut off. Even if scrolling is enabled, box-shadow may not be considered "extra content" and therefore remain non-scrollable within the element.

Answer №3

.customImgEffect{
text-shadow: 2px 2px 4px rgba(0,0,255,0.8);
-moz-text-shadow: 2px 2px 4px rgba(0,0,255,0.8);
-webkit-text-shadow: 2px 2px 6px rgba(0,0,255,0.8);
-o-text-shadow: 2px 2px 4px rgba(0,0,255,0.8);
}

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

How to assign attributes to multiple menu items in WordPress without using JavaScript

I'm currently working on adding attributes to each item in my WordPress navbar. Here is what I have at the moment: <ul id="menu-nav-bar" class="menu"> <li><a href="#text">text</a></li> <li><a href="#car ...

Is your CPU overheating due to IE7, encountering script issues, and need help with debugging

My current web design project is running smoothly on all Mac browsers and Windows Firefox, Chrome, and IE 8. However, I'm facing significant issues with IE 7. Despite having the CSS almost in place with a few adjustments needed, the CPU usage spikes t ...

Adjust the transparency of CSS elements using a jQuery selector

I am developing a grid of brand thumbnails with interactive icons. When one of the icons is hovered, I want all the icons to change opacity and become visible. Here is the current HTML structure: <div id="brands-wrapper"> <img class="brands" ...

Can you guide me on setting a background image URL for rails using javascript?

Within my Rails application, I have a collection of content paired with image buttons (each piece of content has an associated image). When a user clicks on one of these buttons, my goal is to display the corresponding image. All of my images are stored u ...

Unlock the Full Potential: Enabling Javascript's Superpowers through PHP Execution

I specialize in PHP and JavaScript. Currently, I am attempting to incorporate JavaScript functionalities into my PHP code. However, I am encountering an issue where the code is not functioning properly. The PHP code that executes the JavaScript code is as ...

Execute an ajax function when a form is submitted on Marketo

My Request I am seeking assistance with integrating a Marketo script in a WordPress plugin. Upon submission of the Marketo form, I need to perform calculations using the form elements and display the results on the page. Please provide suggestions on ho ...

modify an element using jquery

Hey there! I'm facing an issue where I have an ID of #item_quantity in a span, and I want it to refresh its contents once a button with the ID of #update_cart is clicked. It seems that everything else updates fine on click, but for some reason, the sp ...

How big should the placeholder image be for the image area?

How can I create a loading image to replace a .gif while it loads? I need a placeholder image of about 325x325 (same size as the gif) to keep content in place. I've attempted using background: url() without success and haven't explored JS/jQuery ...

Is jQuery failing to serialize the form data?

I have a question regarding my form. When I try to serialize it using a jQuery script, the output is empty. Could someone please assist me with this issue? Here is a snippet of my form: <form id="tabb2"> <!-- *************************** ...

Apache causes HTML download tag to malfunction

I have an HTML file that includes the following code: <a href="/Library/WebServer/Documents/file.zip" download="file.zip"> Download here </a> When I test this HTML page on Chrome, it successfully allows me to download the file. However, when ...

What is the best way to iterate over an array in PHP and display each element within an <li> HTML tag?

I need help with a PHP script to iterate through an array and store the items in a <li> tag. I am struggling to get the names to display properly. The count of array items is showing up, but not the names themselves. <ul> <?php ...

Investigating the issue of jQuery autocomplete combobox line items breaking in all versions of Internet Explorer. Let's dive into this matter

Having an autocomplete combobox within a div that expands into a dialog box presents visual issues in Internet Explorer. The line items are tightly packed together and the text is not fully visible. To replicate this error, you can obtain the source code d ...

Creating a Background Image Using CSS3: A Step-by-Step Guide

Hey there! I'm trying to figure out how to recreate the image attached using CSS3. I've tried a few online tools for generating gradients, but no luck so far. :( I have the original image, but I really want to create the background using CSS3 in ...

CSS-only Tooltip: text is getting truncated

I am experimenting with adding tooltips to my forum posts. Short tooltips work fine, but longer ones are causing issues by cutting off text. Changing the position property from relative to absolute fixes this problem, but causes the text to overlap. Here ...

unable to execute PHP code

I am attempting to execute a PHP file that will update a database. On Chrome, I am encountering this error: This is the code I have in my index.html file: <!DOCTYPE html> <html> <body> <input type="text" id="descriptioninput"> ...

Reorganize containers without relying on bootstrap styling

Is there a method to rearrange the order of two divs without using the bootstrap library? <div class='parent'> <div class='child-1'>Abc..</div> <div class='child-2'>Xyz..</div> </div> I ...

Declining Effects of AJAX using jQuery

Hi there, I am currently working with an AJAX script that is a combination of jQuery 1.4.4 and jQuery address 1.3.2. What I'm trying to achieve is to make the transitions between divs more smooth by fading them in and out instead of just changing abru ...

Adding text to a newly appended element using jQuery

I am confident in my ability to accomplish this task $('.intro').append('<p>this is my text</p>'); However, I have a question about how to add text to the new element by chaining it $('.intro').append(' ...

Conflicting styles between Bootstrap and Formstack are causing radio buttons to appear only partially visible

Encountering a conflict between Bootstrap (4.1.3) and Formstack CSS when trying to embed a form in a website. The radio buttons are not fully visible, with the issue located in the "label" class ("fsOptionLabel"). Adjusting the line height provides a parti ...

Is it possible to incorporate a jQuery widget within a table?

Can the jQuery sortable widget be utilized within a table, or is it designed to function separately? Here is the link to the jQuery widget for reference - http://jqueryui.com/sortable/#default ...