Square div with side arrow using CSS

I have a div containing an image that should only appear when an element is hovered over. I would like to add a side arrow pointing towards the direction of the hovered element.

Below is the code for generating the square div:

<div id="image-thumbnail-container">
    <img id="image-thumbnail" class="arrow-right">
    <div class="triangle"></div>
</div>

CSS styling:

#image-thumbnail-container {
    display: block,
    position: fixed,
    padding: 4px,
    border-radius: 5px,
}

#image-thumbnail {
    display: block,
    position: fixed,
    border: 1px solid #000,
    padding: 4px,
    border-radius: 5px,
}

.triangle {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 10px 0 10px 17.3px;
    border-color: transparent transparent transparent #ff0055;
}

Here is an example (not exact representation of the generated code):

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

I know how to create the arrow and the background div separately, but I am looking for a way to seamlessly connect them with smooth borders as shown in this sample:

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

If achieving this seems complex, any suggestions on creating an arrow with a background suitable for transparent images are appreciated!

Thank you!

Answer №1

Here is a helpful suggestion for you.

.arrow{
position: relative;
background: #88b7d5;
border: 4px solid #c2e1f5;
  width: 250px;
  height: 350px;
}
.arrow:after, .arrow:before {
left: 100%;
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}

.arrow:after {
border-color: rgba(136, 183, 213, 0);
border-left-color: #88b7d5;
border-width: 30px;
margin-top: -30px;
}
.arrow:before {
border-color: rgba(194, 225, 245, 0);
border-left-color: #c2e1f5;
border-width: 36px;
margin-top: -36px;
}
<div class="arrow"></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

"Customize your text alignment with TinyMCE's align

I'm in the process of updating from an outdated version of TinyMCE to the most recent release. In the old TinyMCE, if you inserted an image and aligned it to the left, the HTML generated looked like this: < img src="testing.jpg" align="left" > ...

Retrieve a text and save it into a variable

Is there a way to extract a specific string and save it as a variable? For example, if I have the following URL: http://sub.site.com/WordsHere-t.jpg I am looking to extract just WordsHere. The length of this string can vary and will not always be 9 chara ...

What could be causing my Node.js website to have trouble locating pages in the public directory?

Embarking on my journey in web development using node.js, I encountered an issue while trying to load a particular page, which led to the following error message in my browser: Cannot GET /public/pages/terms-and-conditions.html The file structure is orga ...

What is the best way to customize the styles of md-input-container in Angular 2?

Below is the code snippet for a md-input-container using angular material design: <md-input-container> <input mdInput [placeholder]="'common.password' | translate" type="password" formControlName="password" (change)="onPasswordCh ...

Getting user input with JQuery and dynamically updating CSS properties

<img src="purplemoon.png" alt="Purple moon" id="moon-photo" /> <table> <tr> <th colspan="4">Control panel</th> </tr> <tr> <td> <!-- attempting to retrieve value from the input field ...

What steps can be taken to ensure express Node.JS replies to a request efficiently during periods of high workload

I am currently developing a Node.js web processor that takes approximately 1 minute to process. I make a POST request to my server and then retrieve the status using a GET request. Here is a simplified version of my code: // Setting up Express const app = ...

Having trouble retrieving data from fetch operation

Having trouble with pulling and displaying search results on the Left page using the SearchFilms component? The API key has been deliberately removed, making it difficult for beginners to figure out what to do. Where should we start? import React, {Fragm ...

TradingView widget chart embedded within a web page is failing to display when hosted on X

I am having trouble displaying a TradingView widget. When I embed the widget in an HTML file and open it in a regular browser, the chart shows up fine. However, when I embed the widget in a PHP or HTML file and try to open it using xampp, the browser doesn ...

Troubleshooting: Inefficient multiple name selection with Jquery

Hey there, I'm currently testing some code for my website that involves selecting multiple names using jQuery. However, I'm encountering an issue where only one of the checkbox groups is working. The goal is to allow users to select only one opt ...

Loading a page with a Chitika ad using Jquery can cause site malfunctions

I am experiencing an issue with my header.php file on my website. I included another PHP file for my ad code, but it seems to load the ad and then redirect me to a blank page. Can someone please review my code and let me know if there is an error? Thank yo ...

Odd behavior observed while running npm scripts in the npm terminal

Included in my package.json file are the following dependencies: "devDependencies": { "chromedriver": "^2.37.0", "geckodriver": "^1.11.0", "nightwatch": "^0.9.20", "selenium-server": "^3.11.0" }, "scripts": { "e2e": "nightwatch -c test ...

Attempting to alter CSS styles programmatically using JavaScript is proving to be ineffective

After trying numerous methods, I have come to the conclusion that the current approach works for others but not for me. Can anyone suggest an alternative way to write this code? Current CSS .aw-widget-current-inner div.aw-widget-content a.aw-current-weat ...

The compatibility issue between Angular's ngModel and Value in input components

Encountering a challenge with the angular form. My objective is to create a form pre-filled with default values that can be edited. Upon validation, the form should submit the data to the MySQL database. Below is the component.html code: <form #adopt=& ...

Using HTML5 video with cue points and stop points

I've noticed that there are various options available for implementing cuepoints in HTML5 videos, such as using PopcornJS or CuepointsJS to trigger play events at specific times within the video track. However, I am wondering if there is a solution t ...

Load additional content seamlessly using Ajax in Django without needing to reload the entire navigation bar

I recently started working with Django as I develop my own website. I have created a base.html file which includes the main body, CSS, js, fonts, and navbar that will be present on all pages of my site. The navbar is located in another HTML file called nav ...

Displaying a JSON response in a jQuery alert box

{ user: [ { id: 476, customer: { id: "375", name: "test", avatar: null, email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail=" ...

Getting an array of objects using AJAX in ASP.NET MVC

I've been working on generating a list using AJAX and sending it to a controller. Here's what I have so far: var objects = new Array(); here is a loop { var object = { a: 1, b: 2, c: 3 }; objects[i] ...

Accessing and assigning an ID to a particular line in a text file using JavaScript

I have a plain text document formatted as follows... Hello . world . . . . its me The code I am currently using to access the text file is as follows: <head> <script type="text/javascript"> function fetchTextFile(); </script> < ...

align all items centrally and customize Excel columns based on the length of the data

Is there a way to dynamically adjust the column width based on the length of data in an Excel report using PHPexcel? Additionally, how can I center all the data in the Excel sheet? Here is the current code snippet: <?php if (!isset($_POST['send&a ...

Adjust the colors of the borders upon clicking the button

Hello, I'm attempting to create a function where clicking on one button changes its border color to blue and changes the border color of all other buttons to orange. However, I'm encountering an issue where the border color for the other buttons ...