Jump to content

Class IDs list?

Recommended Posts

Posted
48 minutes ago, Blackbearsfire said:

Is there a list of class IDs to target different types of images with custom css?

You can use the following extension to get page id, section id, block id: Squarespace ID Finder

 

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> 🤖 Ask me anything

Posted
On 11/3/2022 at 9:38 AM, Blackbearsfire said:

Is there a list of class IDs to target different types of images with custom css?

To target Image in Image Blocks, Gallery Block, Summary Block, you can use Block ID

To target Section Background Image, List Section Image, Gallery Section Image, you can use data-section-id

You can use this tool to find block id, data section id.

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

  • 1 year later...
Posted

What if I want to target all images? I want to show Alt text on mouse hover on all images, and if there is no Alt text just CompanyName, is it possible?

Got this script, but not sure what to correct:

<script>
document.addEventListener('DOMContentLoaded', function() {
  const images = document.querySelectorAll('img');
  images.forEach(img => {
    const altText = img.getAttribute('alt') || 'Decoflame';
    img.setAttribute('title', altText);

    // Optional: Custom tooltip for hover
    img.addEventListener('mouseover', function() {
      const tooltip = document.createElement('div');
      tooltip.textContent = altText;
      tooltip.style.position = 'absolute';
      tooltip.style.background = 'white';
      tooltip.style.border = '1px solid black';
      tooltip.style.padding = '5px';
      document.body.appendChild(tooltip);

      img.addEventListener('mousemove', function(e) {
        tooltip.style.top = e.pageY + 10 + 'px';
        tooltip.style.left = e.pageX + 10 + 'px';
      });

      img.addEventListener('mouseout', function() {
        document.body.removeChild(tooltip);
      });
    });
  });
});
</script>

 

Posted
On 5/16/2024 at 6:21 PM, Ikko-ikki said:

What if I want to target all images? I want to show Alt text on mouse hover on all images, and if there is no Alt text just CompanyName, is it possible?

Got this script, but not sure what to correct:

<script>
document.addEventListener('DOMContentLoaded', function() {
  const images = document.querySelectorAll('img');
  images.forEach(img => {
    const altText = img.getAttribute('alt') || 'Decoflame';
    img.setAttribute('title', altText);

    // Optional: Custom tooltip for hover
    img.addEventListener('mouseover', function() {
      const tooltip = document.createElement('div');
      tooltip.textContent = altText;
      tooltip.style.position = 'absolute';
      tooltip.style.background = 'white';
      tooltip.style.border = '1px solid black';
      tooltip.style.padding = '5px';
      document.body.appendChild(tooltip);

      img.addEventListener('mousemove', function(e) {
        tooltip.style.top = e.pageY + 10 + 'px';
        tooltip.style.left = e.pageX + 10 + 'px';
      });

      img.addEventListener('mouseout', function() {
        document.body.removeChild(tooltip);
      });
    });
  });
});
</script>

 

All Image has ID

img

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.