To hide the open button, simply add display:none
:
.sidebar-button {
line-height: 70px;
color: #eee;
font-size: 25px;
margin-left: 20px;
cursor:pointer
}
.sidebar-button:hover {
color: #b9b9b9;
}
/** The open button isn't visible by default, since the sidebar is already open **/
#open-button {
display:none;
}
Then, adjust which button has display:none
and display:block
based on whether the sidebar is open or closed:
function openNav() {
document.getElementById("sidenav").style.width = "250px";
document.getElementById("close-button").style.display = "block";
document.getElementById("open-button").style.display = "none";
}
function closeNav() {
document.getElementById("sidenav").style.width = "0";
document.getElementById("close-button").style.display = "none";
document.getElementById("open-button").style.display = "block";
}
You may also want to add user-select: none;
to the buttons to prevent them from being selected as text.
Full code snippet:
function openNav() {
document.getElementById("sidenav").style.width = "250px";
document.getElementById("close-button").style.display = "block";
document.getElementById("open-button").style.display = "none";
}
function closeNav() {
document.getElementById("sidenav").style.width = "0";
document.getElementById("close-button").style.display = "none";
document.getElementById("open-button").style.display = "block";
}
body {
background-color: #fcfcfc;
font-family: Roboto, Arial, sans-serif;
}
.sidebar-button {
line-height: 70px;
color: #eee;
font-size: 25px;
margin-left: 20px;
cursor: pointer;
user-select: none;
}
.sidebar-button:hover {
color: #b9b9b9;
}
/** The open button isn't visible by default, since the sidebar is already open **/
#open-button {
display: none;
}
.header {
width: 100%;
height: 70px;
top: 0;
left: 0;
position: fixed;
background-color: #fff;
border-bottom: 1px solid #eee;
}
.toggle {
width: 250px;
height: 70px;
border-right: 1px solid #eee;
position: fixed;
top: 0;
left: 0;
}
.sidenav {
height: 100%;
width: 250px;
top: 0;
left: 0;
position: fixed;
z-index: 1;
overflow-x: hidden;
transition: 0.3s;
margin-top: 71px;
background-color: #fff;
border-right: 1px solid #eee;
line-height: 80px;
overflow: hidden;
}
.sidebar-videos {
font-size: 18px;
text-align: center;
}
.uploadvideo {
color: #707070;
text-align: center;
text-transform: uppercase;
font-size: 14px;
width: 250px;
height: 80px;
border-bottom: 1px solid #eee;
margin-bottom: 10px;
}
.thumbnail {
border: 1px solid #eee;
height: 120px;
width: 200px;
margin-left: 22px;
cursor: pointer;
margin-bottom: 15px;
}
.thumbnail:hover {
border: 1px solid #b9b9b9;
}
.upload-btn-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
}
.btn {
cursor: pointer;
border: 1px solid #eee;
background-color: #8BC34A;
padding: 13px 15px;
color: #fff;
}
.upload-btn-wrapper input[type=file] {
font-size: 100px;
position: absolute;
left: 0;
top: 0;
opacity: 0;
}
.search {
float: right;
width: 250px;
height: 70px;
border-left: 1px solid #eee;
}
<!DOCTYPE html>
<html>
<head>
<title>Video CMS</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/sidebar.js"></script>
</head>
<body>
<div class="header">
<div class="search"></div>
</div>
<div class="toggle">
<div class="group-buttons"></div>
<span class="sidebar-button" id="close-button" onclick="closeNav()">←</span>
<span class="sidebar-button" id="open-button" onclick="openNav()">→</span>
</div>
<div id="sidenav" class="sidenav">
<div class="uploadvideo">
<div class="upload-btn-wrapper">
<button class="btn">Video Uploaden</button>
<input type="file" name="myfile" />
</div>
</div>
<div class=thumbnail"></div>
<div class="thumbnail"></div>
<div class="thumbnail"></div>
<div class="thumbnail"></div>
</div>
</body>
</html>