Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 向下滚动后在右下角显示toast(引导程序5)_Javascript_Html_Toast_Bootstrap 5 - Fatal编程技术网

Javascript 向下滚动后在右下角显示toast(引导程序5)

Javascript 向下滚动后在右下角显示toast(引导程序5),javascript,html,toast,bootstrap-5,Javascript,Html,Toast,Bootstrap 5,使用类bottom-0end-0(至少是我使用它们的方式)无法达到我预期的结果。我想我不了解css和定位的一些非常基本的东西 下面是该代码的一个最小自包含示例: /** *用法:showtoos('hey!','success'); */ 功能显示烤面包片(烤面包片主体、颜色){ 无功延迟=3000; 变量html= ` ${toastBody} `; var toastElement=htmlToElement(html); var toast conainerement=documen

使用类
bottom-0end-0
(至少是我使用它们的方式)无法达到我预期的结果。我想我不了解css和定位的一些非常基本的东西

下面是该代码的一个最小自包含示例:


/** 
*用法:showtoos('hey!','success');
*/
功能显示烤面包片(烤面包片主体、颜色){
无功延迟=3000;
变量html=
`
${toastBody}
`;
var toastElement=htmlToElement(html);
var toast conainerement=document.getElementById(“toast容器”);
toastConainerElement.appendChild(toastElement);
var toast=new bootstrap.toast(toastElement,{delay:delay,animation:true});
toast.show();
setTimeout(()=>toastElement.remove(),delay+3000);//留出一定的空白以允许“隐藏toast动画”
}
/**
*@param{String}HTML表示单个元素
*@return{Element}
*/
函数htmlToElement(html){
var template=document.createElement('template');
html=html.trim();//结果永远不返回空白文本节点
template.innerHTML=html;
返回template.content.firstChild;
}      
吐司测试

向下滚动以单击测试按钮。。。

点击我,祝酒词应该出现在我的右边

/** 
*用法:showtoos('hey!','success');
*/
功能显示烤面包片(烤面包片主体、颜色){
无功延迟=3000;
变量html=
`
${toastBody}
`;
var toastElement=htmlToElement(html);
var toast conainerement=document.getElementById(“toast容器”);
toastConainerElement.appendChild(toastElement);
var toast=new bootstrap.toast(toastElement,{delay:delay,animation:true});
toast.show();
setTimeout(()=>toastElement.remove(),delay+3000);//留出一定的空白以允许“隐藏toast动画”
}
/**
*@param{String}HTML表示单个元素
*@return{Element}
*/
函数htmlToElement(html){
var template=document.createElement('template');
html=html.trim();//结果永远不返回空白文本节点
template.innerHTML=html;
返回template.content.firstChild;
}      
吐司测试

向下滚动以单击测试按钮。。。

点击我,祝酒词应该出现在我的右边
我找到了答案:


页边距底部:1200px
是故意的,以强制人为向下滚动,以获得最小的示例我已经测试了您的代码,重新添加向下滚动,并且toast显示在按钮上方。我假定除了删除
页边距底部:1200px
之外没有做任何更改,因此代码还没有工作。是的,我的回答中没有更改内联css删除。然后,您的其他css出现了一些问题。我尝试在删除页边距底部后使用您的代码:1200px css及其工作方式&在页面右下角显示土司。