Add a shadow to the image and display a semi-transparent triangle when hovered over

Can you help me achieve the effect of showing a cut edge and darkened view when someone hovers over an image, as shown in the example below with the arrow pointing towards it?

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

I'm new to programming and eager to learn. If you could provide sample code to create this type of view, I would be very grateful.

Your assistance is highly valued.

Many thanks.

Answer №1

In order to avoid confusion, I have opted for adding an extra element (an arrow) instead of using a pseudo-element method to create the arrow. For a more detailed explanation, check out the code comments below.

If you want to understand how the arrow was implemented, check out this demo first: Understanding CSS triangles

.image {
  width: 250px;
  height: 200px;
  background: black;
  position: relative;
  overflow: hidden;
}
.image img {
  transition: all ease 1s;
}
.image:hover img { /* Darkening effect on mouseover */
  background: black;
  opacity: 0.7;
}
.image .arrow { /* Creates a half triangle with top and left arrow transparent */
  opacity: 0;
  border-color: transparent #f2f2f2 #f2f2f2 transparent;
  transition: all ease 1s;
  position: relative;
}
.image:hover .arrow { /* Mouseover effect */
  opacity: 1;
  font-family: Roboto;
  font-size: 36px;
  text-align: center;
  border-image: none;
  border-style: solid;
  border-width: 45px;
  position: absolute;
  bottom: 0;
  font-weight: normal;
  width: 0;
  height: 0;
  right: 0;
}

/* More CSS code here */

<div class="image">
  <img src="http://lorempixel.com/250/200/sports" />
  <div class="arrow"><span>></span></div>
</div>

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

Removing modules that are loaded lazily in Angular 5

Is it possible to unload all previously used modules when a user logs out of the website in order to reset the application? I have noticed that when a new user logs into the backend server with the same running application, all lazy loaded modules are stil ...

PHP file is functioning properly, yet no Ajax response received

I have a straightforward sign-up form for a mailing list. It sends the user's email address to a store-address.php file using jQuery's ajax object to make the request and receive a response. The issue I'm facing is that I'm not receivi ...

What is the best way to retrieve the $index variable from an ng-repeat loop within my JSTL code?

I am facing a challenge with a div block that utilizes an ng-repeat. In this Angular loop, I need to incorporate a JSTL loop as well, where I require the current index of the outer Angular loop. Here is a simplified version of the structure: <div ng-r ...

Customizing Carousel Arrows in Angular with ng-bootstrap

I need help changing the position and icon of control arrows using Bootstrap. I've tried targeting "carousel-control-prev-icon" & "carousel-control-next-icon", but nothing seems to work. Any suggestions on how to properly solve this issue? Here is th ...

Is there a way for rainyday.js to utilize a CSS background image as its background?

I have a simple website with a fixed, full-sized background set using CSS. I am trying to incorporate rainyday.js to create a rain effect over the entire site, including the text. Currently, I am only able to get rainyday.js to display rain over a small s ...

How can I horizontally center an element in CSS/HTML if auto-margin does not produce the desired result?

This is a snippet of the CSS code I'm using for my menu: ul { text-align: left; display: inline; margin: auto; width: 50%; position: fixed; top: 0; list-style: none; } I've attempted to use auto-margin left and right ...

Generate a menu submenu allowing for interactive toggling and dynamic visualization of expandable/collapsible sections upon clicking, featuring visually

Looking for assistance in creating a dynamic menu with sub-menus that can expand upon clicking. The goal is to have an expandable menu structure where the user can click to expand or collapse certain sections. However, my current code is not functioning co ...

Tips for resolving the issue of concealing content underneath a preceding element via CSS

I have a unique extension that allows me to modify the HTML of websites. One feature I am working on is adding a span tag containing an SVG tag. While it typically works well, there is an occasional issue where the SVG element is hidden underneath the prec ...

Properly specify the type annotation for a view function that does not accept any arguments

As I continue my Elm learning journey, I have come across a beginner's question. I'm struggling to properly type annotate a function that simply returns a pure div element. header = div [] [ text "Hello" ] Can someone provide guidance on th ...

Leveraging HTML::Template inside a value attribute

Could someone please help me understand how to use an HTML::Template tag within a form field value in order to dynamically change that field? For example: <table border="0" cellpadding="8" cellspacing="1"> <tr> <td align= ...

Navigating through DOM object in jQuery - A Step by Step Guide

I'm facing a challenge with my HTML code. How can I navigate to the <br> tag using jQuery? Constraints: Avoid using class attributes. Do not utilize the split method. For instance: <html> <body> <div> <div> hello ...

What is the best way to align text in "reverse order" to the center?

While utilizing text-align: center, I noticed that the remainder remains at the end. Here is how it currently looks: https://i.sstatic.net/DjQU4.png However, I am seeking to achieve this effect where the remainder remains at the start: https://i.sstatic ...

The div functions seem to stop working properly after they have been multiplied

Initially, I use JavaScript to multiply the div but then encounter issues with the function not working properly. function setDoorCount(count) { $('.doors').html(''); for (var i = 0; i < count; i++) { var content = " ...

retrieve the identification number associated with a specific value

How can I retrieve the value of this ID, which is sent from the controller and displayed in the table? https://i.sstatic.net/UbdxT.png This is my HTML code: <tbody class="no-border-x"> <tr> <td id="id"></td> <td i ...

Is it possible to modify the :hover effects of a material-ui outlined select component?

I am currently developing a react application using Material UI. My goal is to change the color of a selector to white when hovering over it. However, I have encountered difficulties in applying the style as intended. Even when directly adding classes, the ...

Submitting a PHP form by uploading an image with AJAX

I'm looking to submit form data to a MySQL database using AJAX. While I'm not very familiar with AJAX, I managed to write a code that successfully submits text data to the database. However, I'm facing issues with uploading and storing image ...

Why is Selenium failing to retrieve the contents of a class?

PATH = "D:\CDriver\chromedriver.exe" driver = webdriver.Chrome(PATH) driver.get('https://www.se.com/ww/en/about-us/careers/job-details/inside-sales-associate/006ZMV') TITLE = driver.find_element_by_class_name('sdl-applica ...

The elements are out of sync and not properly aligned

Having trouble creating a navbar and encountering two issues. The search text bar's width is not 100%, it should fill the width to 100% of its column. The Glyphicons are not vertically aligned. For reference, you can check out this JSFiddle link A ...

Placing one image over another to create a layered effect

I'm having some difficulty overlaying a logo on top of a background image. In my HTML code, the background image is continuously refreshed to appear like a video stream. The image, dublin-rememberance-floor2, is retrieved from a database using JavaScr ...

A step-by-step guide on how to display a specified amount of images in the center of

I'm currently working with a div that displays images dynamically loaded from a database, ranging from 1 to 5 images. The number of images may vary each time, and I need assistance in centering these images inside the div regardless of their quantity. ...