gpt4 book ai didi

javascript - 如何添加关闭按钮以使用 CSS 提醒日志?

转载 作者:太空宇宙 更新时间:2023-11-04 02:10:03 25 4
gpt4 key购买 nike

我正在尝试将此关闭按钮添加到我的 alertify log message .最终显示应该是这样的:

log message wit close button

我已经尝试了 SO 上列出的一些解决方案,但出于某种原因,我无法将关闭按钮移出 alertify log 消息。关闭按钮的溢出总是隐藏的,我试过使用 CSS 设置但它不起作用。

var fn = function() {
alertify.log('How to add close button? <a href="" class="close-icon"></a>');
};

fn();
.close-icon
{
position: absolute;
top: -5px;
right:-5px;
display:block;
box-sizing:border-box;
width:20px;
height:20px;
border-width:3px;
border-style: solid;
border-color:black;
border-radius:100%;
background: -webkit-linear-gradient(-45deg, transparent 0%, transparent 46%, white 46%, white 56%,transparent 56%, transparent 100%), -webkit-linear-gradient(45deg, transparent 0%, transparent 46%, white 46%, white 56%,transparent 56%, transparent 100%);
background-color:black;
box-shadow:0px 0px 5px 2px rgba(0,0,0,0.5);
transition: all 0.3s ease;
}
<link href="https://rawgit.com/alertifyjs/alertify.js/master/dist/css/alertify.css" rel="stylesheet"/>
<script src="https://rawgit.com/alertifyjs/alertify.js/master/dist/js/alertify.js"></script>
<button onclick="fn();">
<span class="ui-button-text">Test</span>
</button>

最佳答案

问题是内容溢出容器,内容被隐藏了。解决此问题的一种简单方法是:

.alertify-logs > div {
overflow: visible;
}

var fn = function() {
alertify.log('How to add close button? <a href="" class="close-icon"></a>');
};

fn();
.close-icon
{
position: absolute;
top: -5px;
right:-5px;
display:block;
box-sizing:border-box;
width:20px;
height:20px;
border-width:3px;
border-style: solid;
border-color:black;
border-radius:100%;
background: -webkit-linear-gradient(-45deg, transparent 0%, transparent 46%, white 46%, white 56%,transparent 56%, transparent 100%), -webkit-linear-gradient(45deg, transparent 0%, transparent 46%, white 46%, white 56%,transparent 56%, transparent 100%);
background-color:black;
box-shadow:0px 0px 5px 2px rgba(0,0,0,0.5);
transition: all 0.3s ease;
}

.alertify-logs > div {
overflow: visible;
}
<link href="https://rawgit.com/alertifyjs/alertify.js/master/dist/css/alertify.css" rel="stylesheet"/>
<script src="https://rawgit.com/alertifyjs/alertify.js/master/dist/js/alertify.js"></script>
<button onclick="fn();">
<span class="ui-button-text">Test</span>
</button>

关于javascript - 如何添加关闭按钮以使用 CSS 提醒日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39924657/

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