居中&中间位置,而不考虑窗口滚动
Center & middle positioning regardless of window scroll
我使用此页面上的"阅读更多"按钮来显示以前的(display:none)div:http://apexhubmobile.co.uk/corporate-friends
问题是,当他们显示时,他们会强制将窗口移到页面顶部以查看它,我尝试将位置更改为固定,然后直到我滚动一点,框才正确显示。
我的目标是让隐藏的div显示在中心&无论用户在页面的下半部分。
<style>
.b1 {float:left;width:292px;background-color:#F2F2F2;margin:0 4px 5px;vertical-align:middle;border:1px solid grey;line-height:0 !important;}
.b2 {line-height:0 !important;}
.f1 {z-index:999;background-color:white;border:1px solid; grey; position:fixed; top:50%; left:50%; height:430px; width:900px; margin:-215px 0 0 -450px; display:none;}
.f2 {width:100%;background-color:silver;text-align:center; font-size:1.2em; color:white;}
.f3 {position:absolute; right: 0;top: 2px; font-size:0.8em;color:black;}
.f4 {width:35%; height:410px; float:left; display:inline-block;padding:15px 0 0 15px;text-align:center;}
.f5 {width:35%;float:left;text-align:center;position:absolute;bottom:15px;}
.f6 {width:65%;float:left;display:inline-block;padding:15px;}
<div id="s38" class="f1"><div class="f2">SEMINARS@THIRTYEIGHT
<span class="f3"> [ <a href="#" onclick="jQuery('#s38').css('display', 'none');">close</a> ] </span></div><div class="f4">
<img src="http://apexhubmobile.co.uk/images/friends/Seminars38.png">
<div class="f5"><a href="http://seminarsthirtyeight.com" target="new">www.seminarsthirtyeight.com</a></div></div><div class="f6">
Seminars@thirtyeight is a centre for continuing professional development for the whole dental team. Our practice and seminar facility are intimate and inspirational. They are the ‘first class’ end of dental education and mentoring. All of the courses are GDC verifiable.
Held within private dental practice 38 Devonshire Street, located in the heart of London’s Harley Street medical district, the aim at Seminars@thirtyeight is to give you an unsurpassed dental training experience, with some of the world’s most gifted dental mentors. Their relaxed and intimate venue ensures you the best opportunity to network at a professional level and meet the top researchers, opinion leaders and coaches within the dental industry.
<div class="b1"><img src="http://apexhubmobile.co.uk/images/friends/16.png"><div class="b2"><a href="#" onclick="jQuery('#s38').css('display', 'initial');"><img src="http://apexhubmobile.co.uk/test/rm.png" onMouseOver="this.src='http://apexhubmobile.co.uk/test/rmy.png'" onMouseOut="this.src='http://apexhubmobile.co.uk/test/rm.png'"></a></div></div>
有什么想法吗?
您的问题是,您设置了属性"href='#'",因此当您单击它时,它会尝试以#anchor为目标,但由于找不到它,它只是将滚动设置为顶部。
您可以删除链接的CSS光标指针中的href属性和样式。
或者在页面上设置锚点。
PS:或者可能将event.preventDefault();
与jQuery 一起使用
相关文章:
- 使用Dnamics CRM 2011中的JavaScript读取子网格的所有记录,而不考虑活动页面
- 在BoilerplateJS浏览器加载所有脚本(在其他模块中),而不考虑激活的模块
- JS toLocaleString始终显示货币符号,而不考虑区域设置
- 在呈现网页时复制网页,而不考虑参考底图的来源
- 如何使用 javascript 获取 UTC 格式的日期,而不考虑当前系统日期
- 转换 JSON 日期,不考虑时区
- 使用XPath选择包含文本的节点,而不考虑CasperJS中的空白
- 我可以修复手机相对于屏幕的背景吗?(注意:不是窗口)
- 使用简单的角度滤波器来替换输入字符串中某些字符串的所有出现,而不考虑大小写和空格
- 角度高图表和ng网格标题不考虑帧宽度
- jQuery/JavaScript代码如何将表导出为CSV文件而不考虑表's大小.看看@jsfiddle链接
- 捕获给定类型的所有事件,而不考虑气泡/目标
- 选项卡分组和选项卡着色:如何将此功能应用于从我的网页打开的选项卡,而不考虑浏览器
- Firefox扩展弹出窗口:关闭弹出窗口而不是窗口
- 关闭选项卡而不关闭窗口
- CSS不透明度转换;在动画过程中不考虑覆盖不透明度
- 如何检测浏览器(不是窗口)关闭事件
- 如何增加光滑块高度,而不考虑其内容
- 如果用户已关闭,则不显示窗口
- 居中&中间位置,而不考虑窗口滚动