下面的面板可以使用css3 resize
属性来调整大小。
但是,它不方便使用,因为可调整大小的图标位于屏幕的右下角。我想调整图像的整个垂直左侧的大小。
https://jsfiddle.net/69vumt4a/
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: "Lato", sans-serif;
}
.sidepanel {
width: 0;
position: fixed;
z-index: 1;
height: 80%;
max-height: 90%;
top: 0;
right: 0;
background-color: #111;
overflow-x: hidden;
padding-top: 60px;
border: 2px solid;
resize: both;
overflow: auto;
}
.sidepanel a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
transition: 0.3s;
}
.sidepanel a:hover {
color: #f1f1f1;
}
.sidepanel .closebtn {
position: absolute;
top: 0;
left: 25px;
font-size: 36px;
}
.openbtn {
font-size: 20px;
cursor: pointer;
background-color: #111;
color: white;
padding: 10px 15px;
border: none;
}
.openbtn:hover {
background-color:#444;
}
img{width:100%}
</style>
</head>
<body>
<div id="mySidepanel" class="sidepanel">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<img src="https://picsum.photos/800/800">
</div>
<button class="openbtn" onclick="openNav()">☰ Toggle Sidepanel</button>
<h2>Collapsed Sidepanel</h2>
<p>Click on the hamburger menu/bar icon to open the sidepanel.</p>
<script>
function openNav() {
document.getElementById("mySidepanel").style.width = "650px";
}
function closeNav() {
document.getElementById("mySidepanel").style.width = "0";
}
</script>
</body>
</html>