Here is a very simple solution, it is not something extraordinary. Basically, it uses the selector target
that will apply a style when clicking on the element, applying the visibility: visible
in the element.
"The problem" of this is that it is necessary to reference a tag <a>
, pointing with the href
where you want to redirect, in case the id
the element you want to show.
.principal{
display: flex;
justify-content: center;
}
#borda{
border: 1px solid black;
width: 50px;
height: 50px;
}
#promocao{
width: 50px;
height: 50px;
opacity: 0;
cursor: context-menu;
}
#outros{
width: 200px;
height: 200px;
visibility: hidden;
}
#outros:target{
text-align: center;
visibility: visible;
background: blue;
color: white;
}
<div class="principal">
<div id="borda">
<a href="#outros">
<div id="promocao"></div>
</a>
</div>
<div id="outros"> VOCÊ ACHOU O MEGA CUPOM DE DESCONTO </div>
</div>
Note: I left an edge, to see where is the field that is clickable.
Why are you interested in doing this? Do you have a link from a website that does this to give an example of what you want? Maybe you can just apply one
display: none;
what you want to hide and put in place an element that you can interact with and use to open the hidden image/video.– Douglas
Friend if the stuff will be hidden as you will click on it??
– hugocsl
@Douglas I want to make a promotion on my site, which is basically the customer who finds the image gets 5% off the photo coupon https://youtu.be/i7SgSaRuM5Q?t=94
– sdfw
Depending on how it is implemented, it can be quite easy for a slightly more advanced user to find the image, if he knows how to open the page source (Ctrl+U) or the developer tools (Ctrl+Shift+i). Even so, wouldn’t it simply be the case that you put an invisible div somewhere on the page, which will react when the cursor passes over it or when it is clicked? The reaction of div would be to call a javascript code (or have a CSS
::before
) that brings up the coupon. That would be it?– Douglas
Yes! Just like you do?
– sdfw
@Douglas Yes! Just like you do?
– sdfw
On the link you put in the comment, I saw them use
opacity: 0;
to make the element invisible. I tested it in a video suggestion on the side and what happened is that the suggestion "disappeared" (because it was 100% transparent) but it continued occupying its space, and it was still possible to click it (the cursor also changes when passing over it normally) and open the video. Maybe this is the easiest solution for you:opacity: 0;
, and make her haveopacity: 1;
when there is eventhover
in it. You don’t even need javascript.– Douglas
camouflage with Hidden the video or image and hide the link somewhere or several objects to confuse, misleading. , use php so the user will not see which link is correct
– user61936
@Douglas Could you explain me better? Or send me everything ready!
– sdfw
Mano se vc quer fazer igual ao vídeo que vc citou no link your site will take om punishment from Google sooner or later. This is practice
black hat
and you may even be banned from Google search results... gets the tip– hugocsl