Friday, May 30, 2025
News PouroverAI
Visit PourOver.AI
No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
News PouroverAI
No Result
View All Result

Progressively Enhanced Popover Toggletips

May 27, 2024
in Front-Tech
Reading Time: 2 mins read
0 0
A A
0
Share on FacebookShare on Twitter



The CSS Anchor Positioning specification allows us to position elements relative to an anchor on our web page. I am particularly excited about being able to combine anchor positioning with the Popover API to show and hide elements, as mentioned in a recent post.

Anchor positioning is currently only supported in the latest Chrome release. Below is a code experiment demonstrating anchor-positioned toggletips using text from Manifesto for a Humane Web. In browsers that do not support anchor positioning, simple anchor links are used to navigate to the article references. In supporting browsers, buttons replace the anchor links to open popovers displaying the references relative to the article’s position.

See the Pen
Progressively enhanced popover toggletips by Michelle Barker (@michellebarker)
on CodePen.

I could choose to hide the list when anchor positioning is supported, but I believe including references as a list in addition to within the document is more user-friendly.

One downside is the need for content duplication with this approach. Additionally, I utilize the :has pseudo-class to position the small arrows attached to the bubbles when the popover is open, by styling the ::before pseudo-element of the button.

[popovertarget]:has(+ :popover-open) {
position: relative;
background: yellow;

&::before {
–clip: polygon(50% 0, 100% 100%, 0 100%);
content: ”;
position: absolute;
top: 100%;
left: 50%;
width: 1rem;
height: 1rem;
background: lavender;
transform: translateX(-50%);
-webkit-clip-path: var(–clip);
clip-path: var(–clip);
}
}

This approach requires placing the element with the popover attribute adjacent to the popover trigger (the button) in the HTML.

The reason for not making the arrow part of the bubble itself is that its position changes based on available space. I utilize the position-try properties and at-rule to allow the popover to flip to the left or right, ensuring visibility when activated and preventing overflow.

[popover] {
position-try-options: –pos-left, –pos-right;
position-try-order: most-width;
}

@position-try –pos-left {
left: anchor(var(–anchor) -150%);
}

@position-try –pos-right {
right: anchor(var(–anchor) 150%);
left: auto;
}

Custom properties are used for anchor names to refer to each toggletip’s specific anchor while keeping other positioning values consistent. This may lead to slightly confusing reading, especially as the anchor name resembles a custom property.

[popover] {
–anchor: –ref_1;

position-anchor: var(–anchor);
top: anchor(var(–anchor) 150%);
left: anchor(var(–anchor) -150%);

&#ref_2 {
–anchor: –ref_2;
}

&#ref_3 {
–anchor: –ref_3;
}
}

[popovertarget=”ref_1″] {
anchor-name: –ref_1;
}

[popovertarget=”ref_2″] {
anchor-name: –ref_2;
}

[popovertarget=”ref_3″] {
anchor-name: –ref_3;
}

I prefer to refer to these as “toggletips” rather than tooltips, as they provide supplementary information rather than appearing on hover before clicking. This concept is further explained in Heydon Pickering’s Inclusive Components.



Source link

Tags: cssEnhancedfront endPopoverProgressivelyToggletipsweb designweb development
Previous Post

Climate change behind rising flight turbulence, Transportation Sec’y Buttigieg says

Next Post

Women are now less likely to be in top earning 1% of U.K. finance and professional services jobs than before the pandemic

Related Posts

The essential principles of a good homepage
Front-Tech

The essential principles of a good homepage

June 7, 2024
How to measure and improve user retention
Front-Tech

How to measure and improve user retention

June 6, 2024
Push Animation on Grid Items
Front-Tech

Push Animation on Grid Items

June 5, 2024
How to build a Rails API with rate limiting
Front-Tech

How to build a Rails API with rate limiting

June 4, 2024
Introduction to the B.I.A.S. framework
Front-Tech

Introduction to the B.I.A.S. framework

June 3, 2024
Blue Ridge Ruby is exactly what we need
Front-Tech

Blue Ridge Ruby is exactly what we need

June 3, 2024
Next Post
Women are now less likely to be in top earning 1% of U.K. finance and professional services jobs than before the pandemic

Women are now less likely to be in top earning 1% of U.K. finance and professional services jobs than before the pandemic

Efficient Hardware-Software Co-Design for AI with In-Memory Computing and HW-NAS Optimization

Efficient Hardware-Software Co-Design for AI with In-Memory Computing and HW-NAS Optimization

Top Fintech AI Applications – 101 Blockchains

Top Fintech AI Applications - 101 Blockchains

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
Is C.AI Down? Here Is What To Do Now

Is C.AI Down? Here Is What To Do Now

January 10, 2024
23 Plagiarism Facts and Statistics to Analyze Latest Trends

23 Plagiarism Facts and Statistics to Analyze Latest Trends

June 4, 2024
Implementing User Authentication in React Apps with Appwrite — SitePoint

Implementing User Authentication in React Apps with Appwrite — SitePoint

January 30, 2024
Accenture creates a regulatory document authoring solution using AWS generative AI services

Accenture creates a regulatory document authoring solution using AWS generative AI services

February 6, 2024
The 15 Best Python Courses Online in 2024 [Free + Paid]

The 15 Best Python Courses Online in 2024 [Free + Paid]

April 13, 2024
Managing PDFs in Node.js with pdf-lib

Managing PDFs in Node.js with pdf-lib

November 16, 2023
Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

June 10, 2024
AI Compared: Which Assistant Is the Best?

AI Compared: Which Assistant Is the Best?

June 10, 2024
How insurance companies can use synthetic data to fight bias

How insurance companies can use synthetic data to fight bias

June 10, 2024
5 SLA metrics you should be monitoring

5 SLA metrics you should be monitoring

June 10, 2024
From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

June 10, 2024
UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

June 10, 2024
Facebook Twitter LinkedIn Pinterest RSS
News PouroverAI

The latest news and updates about the AI Technology and Latest Tech Updates around the world... PouroverAI keeps you in the loop.

CATEGORIES

  • AI Technology
  • Automation
  • Blockchain
  • Business
  • Cloud & Programming
  • Data Science & ML
  • Digital Marketing
  • Front-Tech
  • Uncategorized

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 PouroverAI News.
PouroverAI News

No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing

Copyright © 2023 PouroverAI News.
PouroverAI News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In