我又回到了另一个问题/问题我的厚脸皮菜单。我终于完成了它,功能完全正常,直到我在手机上查看它。当我扩展所有菜单时,div将会滚动几个像素。我认为我的问题来自于一些元素具有overflow: hidden
并且body和html高度设置为100%的事实(在另一个文件中,这是索引。我提供的代码来自菜单文件,a分开一个)。这是我的加价:
<div class="wrapper">
<img class="logo" alt="Logo" src="pictures\sigla.png"></img>
<div class="meniu">
<div class="dropdown-meniu">
<div id="buton-meniu" class="buton-meniu" onclick="myFunction(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
<div id="dropdown-meniu-content" class="dropdown-meniu-content">
<div class="dropdown">
<div id="buton-ferestre" class="buton" onclick="expansiune_ferestre()">Ferestre<div id="arrow-up-ferestre" class="arrow-up"></div></div>
<div id="dropdown-ferestre-content" class="dropdown-content">
<ul type="none">
<li><a class="text">S3000</a></li>
<li><a class="text">S8000</a></li>
<li><a class="text">S9000</a></li>
<li><a class="text">Vitraj</a></li>
</ul>
</div>
</div>
<div class="dropdown">
<div id="buton-usi" class="buton" onclick="expansiune_usi()">Usi<div id="arrow-up-usi" class="arrow-up"></div></div>
<div id="dropdown-usi-content" class="dropdown-content">
<ul type="none">
<span><li><a class="text">Intrare</a></li>
<li><a class="text">Siguranta</a></li>
<li><a class="text">Garaj</a></li>
<li><a class="text">Glisante</a></li></span>
<span><li><a class="text">Armonice</a></li></span>
</ul>
</div>
</div>
<div class="buton-s">Aerisire</div>
<div class="dropdown">
<div id="buton-sticla" class="buton" onclick="expansiune_sticla()">Sticla<div id="arrow-up-sticla" class="arrow-up"></div></div>
<div id="dropdown-sticla-content" class="dropdown-content">
<ul type="none">
<li><a class="text">Termopan</a></li>
<li><a class="text">Tripan</a></li>
<li><a class="text">Sablata</a></li>
<li><a class="text">Anti-Efractie</a></li>
</ul>
</div>
</div>
<div class="dropdown">
<div id="buton-feronerie" class="buton" onclick="expansiune_feronerie()">Feronerie<div id="arrow-up-feronerie" class="arrow-up"></div></div>
<div id="dropdown-feronerie-content" class="dropdown-content">
<ul type="none">
<li><a class="text">G.U</a></li>
</ul>
</div>
</div>
<div class="dropdown">
<div id="buton-tehnici" class="buton" onclick="expansiune_tehnici()">Tehnici umbrire<div id="arrow-up-tehnici" class="arrow-up"></div></div>
<div id="dropdown-tehnici-content" class="dropdown-content">
<ul type="none">
<span><li><a class="text">Rulouri</a></li>
<li><a class="text">Rolete</a></li>
<li><a class="text">Jaluzele</a></li>
<li><a class="text">Obloane</a></li></span>
<span><li><a class="text">Plase Insecte</a></li></span>
</ul>
</div>
</div>
<div class="buton-s">Contact</div>
</div>
</div>
</div>
</div>
我使用的CSS就在这里:
html, body{
margin:0px;
padding:0px;
max-width: 100%;
}
.wrapper {
height: 110px;
width: 100%;
max-width: 10000px;
background-color: rgba(0, 0, 0, 0.2);
}
.logo {
float: left;
margin-top: 10px;
margin-left: 5px;
width: 200px;
height: 100px;
}
.meniu {
float: right;
width: auto;
}
.buton-meniu {
display: block;
cursor: pointer;
width: 35px;
margin-right: 30px;
margin-top: 40px;
}
.bar1, .bar2, .bar3 {
width: 35px;
height: 5px;
background-color: #ffff;
background-color: rgba(255, 255, 255, 1);
margin: 6px 0;
transition: 0.4s;
}
.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-9px, 6px);
transform: rotate(-45deg) translate(-9px, 6px);
}
.change .bar2 {
opacity: 0;
}
.change .bar3 {
-webkit-transform: rotate(45deg) translate(-8px, -8px);
transform: rotate(45deg) translate(-8px, -8px);
}
.dropdown-meniu {
position: relative;
display: inline-block;
}
.dropdown-meniu-content {
top: 110px;
position: fixed;
background-color: #ffff;
background-color: rgba(255, 255, 255, 1);
width: 30%;
max-width: 10000px;
height: 100%;
min-height: 1000px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
overflow: auto;
-webkit-overflow-scrolling: touch;
right: 0;
transform: translateX(100%);
transition: transform 0.5s ease;
}
.show {
transform: translateX(0%);
}
.dropdown {
cursor: pointer;
font-family: Oswald;
color: #00a60c;
margin-top: 15px;
margin-left: 5px;
font-size: 1.5em;
}
.dropdown-content {
height: 0px;
overflow: hidden;
transition: height 0.5s;
font-family: Ubuntu;
color: #00a60c;
font-size: 0.8em;
}
#dropdown-usi-content span {
float: left;
}
#dropdown-tehnici-content span {
float: left;
}
.buton {
cursor: pointer;
font-family: Oswald;
color: #00a60c;
margin-top: 15px;
margin-left: 15px;
font-size: 1.5em;
}
.buton-s {
cursor: pointer;
font-family: Oswald;
color: #00a60c;
margin-top: 15px;
margin-left: 15px;
font-size: 1.7em;
}
.expand {
height: 120px;
}
#arrow-up-tehnici {
margin-right: 20px;
}
.arrow-up {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #00a60c;
float: right;
margin-right: 20px;
margin-top: 12px;
transform: rotate(0deg);
transition: transform 0.5s;
}
.rotate {
transform: rotate(180deg);
}
.text {
margin-top: 0px;
}
@media screen and ( max-width: 751px ) {
.dropdown-meniu-content {
width: 100%;
max-width: 7510px;
top: 110px;
}
}
这是我非常草率的JavaScript。如果你有任何建议来简化它等等,我会非常高兴,特别是因为我的观点中扩展菜单元素的代码非常草率我觉得我可以简化它,但我无法弄清楚如何做到这一点。
if (navigator.appName == 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/)) || (typeof $.browser !== "undefined" && $.browser.msie == 1))
{
alert("Va rugam sa folositi alt browser cu site-ul nostru!Internet Explorer este un browser cu probleme de securitate, iar noi nu il suportam, asa ca veti fi redirectionati.Va multumim!");
window.location.replace("http://www.google.com");
}
var button = document.querySelector('#buton-meniu');
var content = document.querySelector('#dropdown-meniu-content');
button.addEventListener('click', function(e) {
e.stopPropagation();
e.currentTarget.classList.toggle('change');
content.classList.toggle('show');
}, true)
document.addEventListener('click', function() {
if (content.classList.contains('show')) {
content.classList.remove('show');
button.classList.remove('change');
}
})
content.addEventListener('click', function(e) {
e.stopPropagation();
})
function expansiune_ferestre() {
document.getElementById("dropdown-ferestre-content").classList.toggle("expand");
document.getElementById("arrow-up-ferestre").classList.toggle("rotate");
}
function expansiune_usi() {
document.getElementById("dropdown-usi-content").classList.toggle("expand");
document.getElementById("arrow-up-usi").classList.toggle("rotate");
}
function expansiune_sticla() {
document.getElementById("dropdown-sticla-content").classList.toggle("expand");
document.getElementById("arrow-up-sticla").classList.toggle("rotate");
}
function expansiune_feronerie() {
document.getElementById("dropdown-feronerie-content").classList.toggle("expand");
document.getElementById("arrow-up-feronerie").classList.toggle("rotate");
}
function expansiune_tehnici() {
document.getElementById("dropdown-tehnici-content").classList.toggle("expand");
document.getElementById("arrow-up-tehnici").classList.toggle("rotate");
}
这是代码的JSFiddle:https://jsfiddle.net/TakeDown/k3zywqqj/。
感谢您的时间,我希望我的问题(如果您计算查看javascript代码的请求)不是/不是太傻了!