gpt4 book ai didi

html - CSS transform 翻译顶部的空 block

转载 作者:行者123 更新时间:2023-11-28 08:44:32 25 4
gpt4 key购买 nike

当我尝试在我的“内容”div 上应用 translate3d(150px,0px,0px); 时,页面顶部出现了一个空 block 。我不知道如何解决它。

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<style>
html, body {
margin: 0;
height: 100%;
}
#side-panel {
color: white;
width: 150px;
height: 100%;
background: #1BA39C;
position: absolute;
top: 0;
left: 0;
transition: all .2s ease-out;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
li {
margin: 0px;
padding: 10px;
}
li:hover {
background-color: red;
}
#nav-bar {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 40px;
background: black;

}
.hide {
transform: translate3d(-150px,0,0);
}
.bodyhide {
transform: translate3d(0,0,0);
}
.show {
transform: translate3d(0,0,0);
}
.bodyshow {
transform: translate3d(150px,0px,0px);
}
#content {
transition: all .2s ease-out;
}
#subcontent {
position: relative;
top: 50px;
}
</style>


<div id="side-panel" class="hide">
<ul>
<li>
<a href='#'>Uno</a>
</li>
<li>
<a href='#'>Dos</a>
</li>
<li>
<a href='#'>Three</a>
</li>
<li>
<a href='#'>Cuatro</a>
</li>
<li>
<a href='#'>Cinco</a>
</li>
</ul>
</div>

<div id='content'>
<div id='nav-bar'>
<button id="panel-button">Panel</button>
</div>
<div id='subcontent'>
<p>Content</p>
</div>
</div>


<script type='text/javascript'>
var panel = document.getElementById("side-panel");
var button = document.getElementById("panel-button");
var myContent = document.getElementById("content");

panel.onclick = function () {
panel.className = "hide";
myContent.className = "bodyhide";
};
button.onclick = function () {
panel.className = "show";
myContent.className = "bodyshow";
};
</script>
</body>

这里是codepen http://codepen.io/sbaglieri/pen/LERQXy

最佳答案

添加空格的不是翻译,而是 #nav-bar 上的 position:fixed

解决此问题的一种方法是将 overflow: hidden 添加到 #content

关于html - CSS transform 翻译顶部的空 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27662730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com