我是javascript和CSS的新手。有没有人知道如何在这个弹出窗口中添加滚动条???
请帮忙。
<style type="text/css">
#PopupOverlay {
display: none;
position: fixed;
left: 0px; right: 0px;
top: 0px; bottom: 0px;
background-color: #000000;
opacity:.75;
}
#PopupWindow {
display: none;
position: absolute;
width: 600px; height: 400px;
left: 50%; top: 50%;
margin: -155px 0 0 -300px;
border: solid 2px #cccccc;
background-color: #ffffff;
}
#PopupWindow h1 {
display: block;
margin: 0;
padding: 3px 5px;
background-color: #cccccc;
text-align: center;
}
这是java脚本部分..........................
<script type="text/javascript"> function OpenPopup() { document.getElementById('PopupOverlay').style.display = 'block'; document.getElementById('PopupWindow').style.display = 'block'; } function ClosePopup() { document.getElementById('PopupOverlay').style.display = 'none'; document.getElementById('PopupWindow').style.display = 'none'; }
答案 0 :(得分:4)
我同意Coop,如果您只想要垂直滚动条,请参考以下内容。
#PopupWindow { overflow-y:scroll }
编辑:还有你在那里的那段代码,可能想要将PopupWindow的z-index设置为比PopupOverlay更大的值。
#PopupOverlay {
display: none;
position: fixed;
left: 0px; right: 0px;
top: 0px; bottom: 0px;
background-color: #000000;
opacity:.75;
z-index:5;
}
#PopupWindow {
display: none;
position: absolute;
width: 600px; height: 400px;
left: 50%; top: 50%;
margin: -155px 0 0 -300px;
border: solid 2px #cccccc;
background-color: #ffffff;
overflow-y:scroll;
z-index:10;
}
答案 1 :(得分:2)
#PopupWindow { overflow: scroll; }