Jump to content

Add URL to whole text block

Go to solution Solved by tuanphan,

Recommended Posts

I'm using hover to reveal text on some images on my site.
I used a tutorial from @inside_the_square  to achieve this - Reveal Text on Hover in Squarespace Fluid Engine — InsideTheSquare.co

My text box is sized to cover the whole image, has a white background, and a link added to the text.  All good.
But, I'd like the whole text box to be clickable, and not just the text.

Website is ** removed **  and the images are at the top of the page.

I've searched the forum and found a solution posted, but this isn't working for me.

Any help greatly appreciated 🙂

Edited by matthewevas
Link to comment

I've tried using the following code: -

/* Select the text box you want to make clickable */
.your-text-box-class {
   /* Add a pointer cursor to indicate that it's clickable */
   cursor: pointer;
}

/* Turn the text box into a link */
.your-text-box-class a {
   /* Remove text decoration */
   text-decoration: none;
   /* Make the link cover the entire text box */
   display: block;
   height: 100%;
   width: 100%;
}

/* Add the section ID to the link */
.your-text-box-class a::before {
   /* Content is empty by default */
   content: "";
   /* Add the section ID to the content */
   attr(href, url) "#section-id";
   /* Hide the content from view */
   display: none;
}

The problem I'm now facing is a syntax error on line    attr(href, url) "#section-id"; 

Can anyone tell me where I'm going wrong with this ?

Thanks in advance !

Link to comment
  • Solution

With first item, add this to Design > Custom CSS

/* make text box clickable */
.fe-block-8f2be76e0c965cf24e1a {
    position: relative;
}

.fe-block-8f2be76e0c965cf24e1a a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
}

 

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!)

Link to comment
6 minutes ago, tuanphan said:

With first item, add this to Design > Custom CSS

/* make text box clickable */
.fe-block-8f2be76e0c965cf24e1a {
    position: relative;
}

.fe-block-8f2be76e0c965cf24e1a a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
}

 

Thanks @tuanphan !  That worked great, but the text is now left aligned and not in the centre.  Do you know how I can correct that ?

Link to comment
  • 6 months later...

Hi @tuanphan,  I am using the code you provide. it work well however the code compress my text line into single line. How can i fix it ?

Here is the code.

/* Make text box clickable */
.fe-65275e92573640628018fb6d .html-block {
  position: relative;
}

.fe-65275e92573640628018fb6d .html-block a {
 position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
   justify-content: center;
}

 

Screenshot 2023-11-07 at 10.54.20 AM.png

Link to comment
On 11/7/2023 at 9:55 AM, yuinia said:

Hi @tuanphan,  I am using the code you provide. it work well however the code compress my text line into single line. How can i fix it ?

Here is the code.

/* Make text box clickable */
.fe-65275e92573640628018fb6d .html-block {
  position: relative;
}

.fe-65275e92573640628018fb6d .html-block a {
 position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
   justify-content: center;
}

 

Screenshot 2023-11-07 at 10.54.20 AM.png

What is this page url?

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!)

Link to comment
  • 2 months later...
On 4/15/2023 at 7:19 AM, tuanphan said:

With first item, add this to Design > Custom CSS

/* make text box clickable */
.fe-block-8f2be76e0c965cf24e1a {
    position: relative;
}

.fe-block-8f2be76e0c965cf24e1a a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
}

 

Where do we insert our block number in this code? Excuse me for not quite understanding it. And does this make the block clickable once I've added a link to the text?

Link to comment
On 2/14/2024 at 7:15 AM, alchemy_newyork said:

Where do we insert our block number in this code? Excuse me for not quite understanding it. And does this make the block clickable once I've added a link to the text?

Recently I wrote this free guide (Shape Block, Text Block, Video, Image are similar), you can follow it. In case you can't make code work, just share link to your site, I will check & give exact code for your case

 

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!)

Link to comment

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.