gpt4 book ai didi

javascript - MS Word 样式的 JS/HTML 下拉菜单(帖子中的图片)

转载 作者:行者123 更新时间:2023-12-03 09:53:54 26 4
gpt4 key购买 nike

所以我想创建一个像这样的下拉菜单(带有缩略图)。我有 5 个 html 元素,我想以这种风格显示。我添加了我的代码,但我不知道如何制作那种风格的下拉菜单。

MS Word

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript">
window.onload = function(){

var c=document.getElementById("leplanner-canvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0, c.height/2);
ctx.lineTo(c.width, c.height/2);
ctx.stroke();

for(var i =0; i< document.getElementsByClassName('box').length; i++){
var box = ".box-"+i;
console.log(i);
$(box).draggable({
grid: [ 72, 12 ],
stop: function( event, ui ) {
console.log('dragstart');
},
stop: function( event, ui ) {

var json = [];

for(var i =0; i< document.getElementsByClassName('box').length; i++){

var b = {
x: document.getElementsByClassName('box')[i].offsetLeft,
y: document.getElementsByClassName('box')[i].offsetTop
/// see asendada koordinaatidega võrreldes canvasega + juurde veel laius ja muu
////http://stackoverflow.com/questions/288699/get-the-position-of-a-div-span-tag
}

json.push(b);

}

//See on see mis ab'i siis läheb
document.getElementsByClassName('json')[0].innerHTML = JSON.stringify(json, null, 2);
},
drag: function( event, ui ) {
//http://api.jqueryui.com/draggable/#event-drag
// siin või jquery ui kaudu tuleks kontrollida, et ei saaks kaste üksteise peale panna
}

});

$(box).resizable({
grid: [ 72, 12 ]
});
}


}


</script>
body,html {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
position: center;
}

.box {
height: 71px;
width: 71px;
margin: 5px;
border: 1px solid gray;
text-align: center;
background-color: #fff;
z-index: 20;
display: inline-block;
}

#leplanner-canvas {
background-color: lightgray;
margin: 0 auto;
position: absolute;
left: 50%;
margin-left: -480px;
z-index: 10;
}

.list {
padding-left:450px;
margin-top: 20px;
margin-left: 190px;
position: float-right:
height: 100px;
width: 10%:
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LePlanner</title>
<style media="screen">



</style>

</head>
<body>
<div class="list">
<div class="box box-0">
Tekst
</div>
<div class="box box-1">
Youtube
</div>
<div class="box box-2">
Twitter
</div>
<div class="box box-3">
Facebook
</div>
<div class="box box-4">
Google
</div>
<div class="box box-5">
Meetod
</div>
</div>
<canvas id="leplanner-canvas" width="960" height="400"></canvas>
<div class="json"></div>
</body>
</html>

最佳答案

它是具有固定尺寸和定制滚动功能的 div。

示例:

.menu {
overflow-x: hidden;
height: 52px;
width: 300px;
border: 1px solid #ddd;
}
.nav {
float: left;
border: 1px solid black;
width: 50px;
height: 50px;
}
.nav:hover {
border-color: yellow;
}
<div class="menu">
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
<div class="nav">MENU</div>
</div>

关于javascript - MS Word 样式的 JS/HTML 下拉菜单(帖子中的图片),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30800458/

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