jQWidgets jqxTagCloud组件是一个标签云控件,可以根据数据的权重动态地显示标签,并支持调整标签的大小和颜色。该组件提供了许多自定义选项,其中高度属性是一个重要的选项,可以控制标签云的高度。
jqxTagCloud高度属性可以通过以下方式设置:
$('#tagCloud').jqxTagCloud({
height: 300
});
上述代码中,设置了id为tagCloud的元素的高度为300像素。
另外,也可以在样式表中设置元素的高度,然后在初始化时不设置高度属性:
#tagCloud {
height: 300px;
}
$('#tagCloud').jqxTagCloud();
这样可以让标签云的高度与样式表中定义的高度一致。
示例1:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jqxTagCloud Demo</title>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.tagcloud.css">
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jquery-3.5.1.min.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxcore.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxdata.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxbuttons.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxscrollbar.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxlistbox.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxdropdownlist.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxtagcloud.js"></script>
</head>
<body>
<div id="tagCloud"></div>
<script>
var data = [
{ label: 'JavaScript', weight: 10 },
{ label: 'HTML', weight: 8 },
{ label: 'CSS', weight: 6 },
{ label: 'jQuery', weight: 5 },
{ label: 'Angular', weight: 4 },
{ label: 'React', weight: 3 }
];
$('#tagCloud').jqxTagCloud({
source: data,
width: '500',
height: 300
});
</script>
</body>
</html>
在上述示例中,创建了一个标签云,并将其高度设置为了300像素。
示例2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jqxTagCloud Demo</title>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.tagcloud.css">
<style>
#tagCloud {
height: 200px;
}
</style>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jquery-3.5.1.min.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxcore.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxdata.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxbuttons.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxscrollbar.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxlistbox.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxdropdownlist.js"></script>
<script src="https://jqwidgets.com/public/jqwidgets/scripts/jqxtagcloud.js"></script>
</head>
<body>
<div id="tagCloud"></div>
<script>
var data = [
{ label: 'JavaScript', weight: 10 },
{ label: 'HTML', weight: 8 },
{ label: 'CSS', weight: 6 },
{ label: 'jQuery', weight: 5 },
{ label: 'Angular', weight: 4 },
{ label: 'React', weight: 3 }
];
$('#tagCloud').jqxTagCloud({
source: data,
width: '500'
});
</script>
</body>
</html>
在上述示例中,创建了一个标签云,并通过样式表将其高度设置为了200像素。
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:jQWidgets jqxTagCloud高度属性 - Python技术站