我试图将滚动位置设置为div
弹出窗口的顶部。它第一次工作但在位置更改后,它不会重置为top
。有什么想法吗?
JS:
function ShowPopupAddLocations() {
ClearPopUpData();
$("#dividEditLocation").scrollTop();
$('#dividEditLocation').show();
return false;
}
CSS:
.popOuter {background:rgba(0,0,0,0.7); width:100%; height:100%; position:fixed; z-index:99; display:none; left:0; top:0;}
.popup_main{ padding:20px; box-sizing:border-box; max-width:700px; width:100%; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); -moz-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -o-transform: translate(-50%, -50%); background:#fafbff;}
.popup_main .popup_content{ position:relative; padding:20px 5px 0 0; max-height:500px; overflow-y:auto;}
.popup_main .popup_content p em{ font-size:20px; color:#cc4b46; font-weight:700; font-style:normal}
.popup_header{ padding-bottom:15px; border-bottom:1px solid #e5e6ea; }
.popup_header h2{ font-size:28px; line-height:30px;}
.popup_close{background:#fafbff url(../images/popclose_btn.png) no-repeat center center; width:20px; height:20px; top:10px; right:10px; position:absolute;}
修改
这是打开的div
<div class="popOuter" id="dividEditLocation"> <div class="popup_main">
<a href="javascript:void(0)" class="popup_close" onclick='funcHideAddressPopUp();'></a>
<div class="popup_header"> <h2>Create Location</h2> </div>
<div class="popup_content" id="dvAddEditLocationDetail"> </div> </div> </div>
答案 0 :(得分:0)
如果切换
$('#dividEditLocation').show();
$("#dividEditLocation").scrollTop();
它可以工作 - div没有任何高度所以它没有滚动条。