Nelson if you fix the syntax leaving only the tag <a>
or using only the tag <button>
the element is clickable because the way you wrote the HTML syntax is invalid. As commented by @hunterxhunter and @Marceloboni
Read more about this in this answer to see what the tag <a>
accepted within it It is acceptable to use <H2>, <H3>, <p>, <div> tags within links/anchors (<a></a>)?
The right thing would be something like
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
z-index: -22;
}
.heroimg {
position: relative;
background-repeat: no-repeat;
background-image: url(https://unsplash.it/100/100);
background-size: cover;
background-position: center;
height: 100%;
/* z-index: -1; */
}
.herotxt {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#circle {
align-items: flex-start;
text-align: center;
cursor: default;
background-color: buttonface;
box-sizing: border-box;
padding: 2px 6px 3px;
border-width: 2px;
border-style: outset;
border-color: buttonface;
border-image: initial;
text-rendering: auto;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
margin: 0em;
font: 400 13.3333px Arial;
}
<div class="heroimg">
<div class="herotxt">
<h1>Informática</h1>
<a href="#btn" id="circle">
<i class="fa fa-chevron-down fa-3x"></i>
</a>
</div>
</div>
You can do a trick by taking the class .heroimg
and take out the z-index: -1
so the element will be clickable.
Note that when removing this it is again clickable.
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.heroimg {
position: relative;
background-repeat: no-repeat;
background-image: url(https://unsplash.it/100/100);
background-size: cover;
background-position: center;
height: 100%;
/* z-index: -1; */
}
.herotxt {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
<div class="heroimg">
<div class="herotxt">
<h1>Informática</h1>
<a href="#btn">
<button id="circle">
<i class="fa fa-chevron-down fa-3x"></i>
</button>
</a>
</div>
</div>
Here’s a Mozilla guide on z-index
that can help you. https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index
Can create a verifiable example to better understand the problem?
– Ricardo Pontual
I strongly believe this HTML syntax is invalid!
<a><button></button></a>
– MarceloBoni
then what would be the right one?
– nelson450
Only
<a>
or<button>
, you stylize the element according to your need and the event in the case of<a>
you omit and emulate the operation of<button>
– MarceloBoni
Nelson really if you tidy up the syntax you will see that the z-index change would not even be necessary. The other answer would be the most correct
– hugocsl
both answers are correct, I just set the syntax here in my code
– nelson450
OK Nelso now no more problem, I edited the question with more details.
– hugocsl