I have a small turnaround. I need your help for a change.
I am practicing on a personal project, the Light Box effect and if possible I would like to listen to the expensive colleague . Be pointing errors or changes for didactic purposes, constructive criticism will always be welcome!
Code
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
border: 1px solid #e7e7e7;
background-color: #f3f3f3;
}
li {
float: left;
}
li a {
display: block;
color: #666;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.ativo) {
background-color: #ddd;
}
li a.ativo {
color: white;
background-color: #4CAF50;
}
.escurecer{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background: black;
z-index:1001;
opacity:.80;
}
#sobre {
display: none;
position: absolute;
top: 30%;
left: 37%;
width: 25%;
height: 37%;
padding: 16px;
border: 3px solid gray;
background-color: white;
z-index:1002;
overflow: auto;
text-align: center;
}
#contato {
display: none;
position: absolute;
top: 30%;
left: 37%;
width: 25%;
height: 37%;
padding: 16px;
border: 3px solid gray;
background-color: white;
z-index:1002;
overflow: auto;
text-align: center;
}
<ul class="topnav">
<li><a class="ativo" href="#inicio">Inicio</a></li>
<li><a href="#contato" onclick="document.getElementById('contato').style.display='block';document.getElementById('escurecer').style.display='block'">Contato</a></li>
<li><a href="#sobre" onclick="document.getElementById('sobre').style.display='block';document.getElementById('escurecer').style.display='block'">Sobre</a></li>
</ul>
<div id="sobre" class="box"><h4>Sobre nós</h4><hr><br>
<p>Lorem ipsum...</p>
</div>
<div id="contato" class="box"><h4>Fale conosco</h4><hr><br>
<p>Lorem ipsum...</p>
</div>
<div id="escurecer" class="escurecer" onclick="document.getElementById('escurecer').style.display='none';document.getElementById('sobre').style.display='none';document.getElementById('contato').style.display='none';"></div>
Problem-IthinkIcouldimprovethefunctionalmodeoftheexcerpt:
<divid="escurecer" class="escurecer" onclick="document.getElementById('escurecer').style.display='none';document.getElementById('sobre').style.display='none';document.getElementById('contato').style.display='none';"></div>
document.getElementById('sobre').style.display='none';
document.getElementById('contato').style.display='none';"
This is to clear / hide the floating divs
.
I wanted to know if anyone proposes something to me .. let's say more beautiful in relation to this repetition of lines.
Reminder - All the source code presented here works round. I just came to pick improvements or alternatives in that particular section. In which I find this very amateur.