【发布时间】:2026-01-04 14:20:02
【问题描述】:
我正在尝试在弹出窗口出现时添加比例效果。这个弹出窗口是可拖动的(感谢 jQuery),只有最小宽度和最小高度,但必须不包含固定大小,因为内容可以动态更改(这是一种可以重复使用的基本弹出窗口用于多个弹出内容)。
$('a.close').click(function() {
$('#box').hide('scale', {
percent: 0,
direction: 'both',
origin: ['middle', 'middle'],
}, 1000);
});
$('#show').click(function() {
$('#box').show('scale', {
percent: 100,
direction: 'both',
origin: ['middle', 'middle'],
easing: 'easeOutBounce',
}, 1000);
});
#box {
position: absolute;
background: #666666;
min-width: 200px;
min-height: 200px;
left: 100px;
top: 100px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="button" name="show" id="show" class="show" value="Show">
<div id="box" style="display:none;">
<a href="#" class="close">Close</a>
</div>
提前致谢。 狮子座
【问题讨论】:
-
min-width和min-height-200px、width和height-fit-content,但请记住,fit-content的跨浏览器兼容性很差。 -
感谢您的回答但是,如果我将 fit-content 设置为 min-width/min-height,则该框将失去其最终尺寸,并将裁剪为“关闭”的内容如果我将 fit-content 设置为宽度/高度,没有发生任何事情
标签: javascript html jquery css effects