How can I implement 'blocked tails' using the :after pseudo-element?

Apologies, I'm uncertain of the right term for these elements. I have a module that reveals another box with information when hovered over. I want them to be visually connected by an angled rectangle or tail to indicate their association.

Something along the lines of: https://i.sstatic.net/cm0Jc.png

I initially attempted to achieve this using a rotated rectangle and an :after element, but it wasn't effective for responsiveness. I would appreciate any suggestions you might have.

This is how I structured the list:

<div class="pp-left">
<ul>
<li class="targ">Target</li>
<li class="conn">Connect</li>
<li class="conv">Convert</li>
<li class="opti">Optimize</li>
</ul>
</div>

Followed by the 'pop ups' with corresponding CSS Classes:

<div class="pp-right">
   <div class="target-popup popup" style="display: none;">
      <p>Build data-rich supporter profiles, segmenting them, and targeting them with one-to-one communications. Create custom groups to segment constituents by activities, interests, giving level, location, etc and set list segmentation conditions that auto-populate and refresh groups daily.</p>
   </div>
</div>

For handling hover effects/show/hide, I am using this function:

$(function() {
    $('.target-popup').show();
    $('.targ, .target-popup').hover(function() {
            $('.target-popup').show();
        },
        function() {
            $('.target-popup').hide();
        });
});

You can view a demo on jsfiddle.

Answer №1

According to your explanation, utilizing a pseudo-element along with a transform involves using a skewY and adjusting the transform-origin.

div {
  width: 150px;
  height: 75px;
  background: orange;
  margin: 1em auto;
  position: relative;
}
div::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 0;
  height: 100%;
  width: 15%;
  background: darkred;
  transform-origin: left top;
  transform: skewY(25deg)
}
<div></div>

Answer №2

Special thanks to Paulie_D for the help in modifying HTML/CSS and adding a div element with the class "indicator". Take a look at the code snippet below:

div.indicator {
   background: orange none repeat scroll 0 0;
   float: left;
   position: relative;
 }

 div.indicator::after {
   background: darkred none repeat scroll 0 0;
   content: "";
   height: 42px;
   left: 150px;
   position: absolute;
   top: -10px;
   transform: skewY(25deg);
   transform-origin: left top 0;
   width: 15px;
 }

To see a demo of this implementation, visit https://jsfiddle.net/q0qzLh74/

It's important to note that I did not make any changes to the jQuery script. Each list item contains a div with the class "indicator", so adjustments are needed in the jQuery code to handle show/hide actions accordingly.

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

Adjust the z-index of the dynamically generated image label to ensure that it is not obscured by the image

Currently, I am working on implementing drag and drop functionality where users can drag multiple images and drop them into a div. Once the user clicks on a button, a p tag is dynamically appended as a label to each image. My issue arises when two images ...

Challenges with implementing CSS transitions

I've been delving into CSS3 transitions, and I'm encountering some confusion. I can't tell if I'm misunderstanding something or if it's the browsers causing issues. Initially, I believed Opera had transition support starting from ...

Troubleshooting the issue with UI-Router AngularJS controller not functioning properly in a

Trying to grasp the ins and outs of UI-Router in conjunction with Angular has proven to be quite challenging for me. In my setup, there's an index: <body> <div ui-view></div> <!--Location of file holding app--> <scri ...

Ways to display an SVG spinner prior to a substantial UI refresh

I am currently facing an issue with updating 10 apexcharts bar charts simultaneously in a Vue app. When this process occurs, it takes approximately one second to load completely, and during that time, I would like to display an svg spinner. However, the co ...

Tips for positioning fixed column headers at the bottom of the header row

I am currently working on a responsive table where the first two columns are fixed and the rest are made to float. However, I have encountered some issues and have a few questions: Why do the headers for the first two columns float to the top of the head ...

How can I assign a default value for a multiple select dropdown list in AngularJS?

I am currently facing an issue with my multiselect dropdown. The code for the dropdown is as follows: <select id="year" multiple ng-model="type" ng-disabled="!type1" > <option value="all" selected>all</option>; <option value= ...

Utilizing Javascript to Open a New Tab from Drupal

I'm attempting to trigger the opening of a new tab when a specific menu link is clicked within a Drupal website. My initial approach was to incorporate JavaScript directly into the content of the page, but unfortunately this method has not been succes ...

An Angular ng-container situated within a row of an HTML table

I am currently working with a Reactive Form that includes a FormArray (similar to a Game Roster containing basic information such as Start At, Prize, Duration, and an array of players). To display the array of players, I have implemented the following: & ...

The issue of children inside a parent div not respecting the height value set to 100% when the parent div has a min

My goal is to adjust the height of children elements within a parent div that has a min-height of 100%. I want the wrapper's height to dynamically adjust based on the content it contains. When I set the min-height to 100%, the wrapper expands accordin ...

Having trouble with image hover functionality on pure CSS?

<div id="headermenu"> <ul > <li id="menu1"><a href="#"><img src="images/menu1.png"/></a></li> <li id="menu2"><a href="#"><img src="images/menu2.png"/></a> < ...

Load jQuery results when scrolling to the top of the window

I have a function that triggers when I click a button to fetch more data from my table. I'm attempting to make it work when the button reaches a certain distance from the top of the window, but I've been unable to achieve this so far... $(funct ...

Preserve the datepicker even after selecting a date

I am currently using the datepicker feature from jQuery UI in my project. Below is a snippet of my initial code: $('#fromDate').datepicker({ showOtherMonths: true, minDate: 0, dateFormat: 'dd MM yy', onSelect: function(dateTex ...

Error encountered while pressing key on vscode led to failure in requesting textDocument/documentLink

Greetings! I'm currently using VSCode on both my mac and Windows 10 machines. Recently, they have both started experiencing the same issue after a recent update/rollback. Every few keystrokes, the output box pops up with the "HTML Language Server" se ...

Troubleshoot: Font Rendering Issue with CSS3 @font-face in Opera 11.x

Having some trouble with Opera not displaying my HTML5 site correctly. Everything looks good in Safari, Chrome, IE9, Firefox 3.5+ and more. Wondering if anyone has encountered this before and found a solution. Here's the breakdown of my setup: In the ...

Issue with Laravel css not being correctly processed by the elixir function in xampp environment

After creating a versioned css file with the following code: elixir(function(mix) { mix.sass('demo.scss') .version('css/demo.css'); }); The file can be found at public/build/demo-34f5737738.css. According to the documentation, ...

Obtain the image format from an HTML page using the Jsoup library on Android

<div class="_jjzlb" style="padding-bottom: 55.2778%;"><img alt="AT Dam party.. #nashik #big #dam" class="_icyx7" id="pImage_11" src="https://instagram.fbom1-2.fna.fbcdn.net/t51.2885-15/e35/17438694_254543168340407_6435023364997251072_n.jpg" style ...

Guide on using timestamps in PHP

I am struggling to incorporate the current date and time of the SO-NUMBER that the user is entering. The issue I'm encountering lies within the IF..ELSE loop, it only updates one column in the database, which is the "samplerecived" column even if I ...

Is there a way to delete a wrapper (parent element) in Angular without deleting the child element as well?

The solution provided in this answer on Stack Overflow addresses jQuery and not Angular or TypeScript. My inquiry bears resemblance to this question raised on a forum, but I am specifically looking for a resolution within the context of Angular. Is there ...

Utilize ajax requests to dynamically enable or disable input fields

Currently, I am developing an attendance management system for employees. The attachment below contains three input fields - one dropdown and two calendar fields. The dropdown includes the names of employees, the second field displays the current date and ...

Why is the editor not displaying the correct line number when the enter key is pressed repeatedly in JavaScript?

I am currently working on developing an editor using JavaScript. My goal is to display a line count (e.g., 1, 2, 3) whenever the user presses 'Enter' to change lines. I have successfully managed to count the line changes upon pressing 'Enter ...