Browse Source

提示框优化

pull/14/head
pengda 7 months ago
parent
commit
664261d924
  1. 11
      view/templates/admin/formula_list.html

11
view/templates/admin/formula_list.html

@ -94,7 +94,7 @@
<td>{$item.name}</td>
<td>{$item.source}</td>
<td>
<div style="display: flex;flex-wrap: wrap;border-bottom: 1px dashed #ccc;padding-bottom: 10px">
<div class="formula-item" style="display: flex;flex-wrap: wrap;border-bottom: 1px dashed #ccc;padding-bottom: 10px">
{foreach from=$item.formula item=value}
<span class="item" style="flex-basis: auto;white-space: nowrap;padding-left:20px">{$value.name}{if $value.desc}({$value.desc}){/if} {$value.num_str}</span>
{/foreach}
@ -237,10 +237,12 @@
}
window.onload = function() {
const items = document.querySelectorAll('.item');
const formulaitems = document.querySelectorAll('.formula-item');
formulaitems.forEach(container => {
const items = container.querySelectorAll('.item');
let maxWidth = 0;
// 获取每个子项的宽度,并计算最大宽度
// 获取每个 container 内部子项的最大宽度
items.forEach(item => {
const itemWidth = item.offsetWidth;
if (itemWidth > maxWidth) {
@ -248,10 +250,11 @@
}
});
// 设置所有子项宽度为最大内容宽度
// 设置所有子项宽度为最大内容宽度
items.forEach(item => {
item.style.flexBasis = maxWidth + 'px';
});
});
};
</script>
<style>

Loading…
Cancel
Save