div

如何始终在屏幕中间显示Div

做~自己de王妃 提交于 2019-12-28 23:54:43
一、在中间显示;(参考: sky100articles1790515 ) Div和样式 .ordersearchDivCss { position: absolute; z-index: 100; display: block; background-color: #6ec1df; } <div class="ordersearchDivCss" id="DivMain" style="width: 400px; height:200px" align="center"></div> Js code 调用:<input type="button" id="Button1" onclick="sc1(‘DivMain’)" /> // JScript 文件 通过元素id得到对象的函数 function $(id) { return document.getElementById(id); } JS控制id 为"div"的层在屏幕中间function sc1(DivId) { var Div = $(DivId); $(DivId).style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight - $(DivId).offsetHeight) / 2) + "px"; $

js 弹出div窗口的效果

混江龙づ霸主 提交于 2019-12-28 05:56:51
IE6、IE7、FireFox 下测试有效。 源文件下载: http://files.cnblogs.com/yangxiaohu1/js-pop-div.rar <html> <head> <title>LIGHTBOX EXAMPLE</title> <style> .black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); } .white_content { display: none; position: absolute; top: 25%; left: 25%; width: 50%; height: 50%; padding: 16px; border: 16px solid orange; background-color: white; z-index:1002; overflow: auto; } </style> </head> <body> <p>可以根据自己要求修改css样式<a href = "javascript:void(0

Div层弹出

余生长醉 提交于 2019-12-28 05:56:27
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>点击文字弹出一个DIV层窗口代码</title> <style> .black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=88); } .white_content { display: none; position: absolute; top: 25%; left: 25%; width: 55%; height: 55%; padding: 20px; border: 10px solid orange; background-color: white; z-index:1002; overflow: auto; } </style> </head> <body> <p>示例弹出层:<a href = "javascript:void(0)" onclick = "document

Codeforces Beta Round #92 (Div. 1 Only) A. Prime Permutation 暴力

元气小坏坏 提交于 2019-12-27 06:51:18
A. Prime Permutation 题目连接: http://www.codeforces.com/contest/123/problem/A Description You are given a string s, consisting of small Latin letters. Let's denote the length of the string as |s|. The characters in the string are numbered starting from 1. Your task is to find out if it is possible to rearrange characters in string s so that for any prime number p ≤ |s| and for any integer i ranging from 1 to |s| / p (inclusive) the following condition was fulfilled sp = sp × i. If the answer is positive, find one way to rearrange the characters. Input The only line contains the initial string s,

案例:简易的Div拖拽

ぐ巨炮叔叔 提交于 2019-12-27 05:43:32
案例:简易的Div拖拽 鼠标移入Div区域后,按下鼠标左键,可以拖动Div移动;松开鼠标左键,Div拖动停止。同时要求Div不能拖出屏幕显示区域外。 拖拽原理:距离不变、三个事件(onmousedown、onmousemove、onmouseup) 解决问题: 1、拖拽过程中,鼠标容易滑出Div区块; 2、防止Div拖出页面:修正位置; 3、解除绑定事件:鼠标左键抬起后,Div不再随着鼠标移动而发生位置变化; <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>习题-拖拽Div滑块</title> <style> * { margin: 0;padding: 0; } div { width: 100px; height: 100px; margin-bottom: 0px; background-color: purple; position: absolute; } </style> <script> window.onload = function () { //此处写代码 } </script> </head> <body> <div id='div1'></div> </body> </html>   参考代码: function getPos(ev) { var

解决拖拽有内容的div的bug和兼容问题

China☆狼群 提交于 2019-12-27 05:19:53
/*--> */ /*--> */ <!DOCTYPE html> <html > <head > < meta charset = "UTF-8" > <title ></title > < style type ="text/css" > #big { height : 800 px ; width : 800 px; background-color : #008000 ; position : relative ; } #small { height : 100 px ; width : 100 px; background-color : orangered; position : absolute ; } </style > </head > <body > < div id ="big" > 拖拽有内容的div,在浏览器上都会有bug 解决FF和chrome上的bug只需要加上return false就可以了 解决低版本IE上的bug就需要用到事件捕获setCapture和释放捕获releaseCapture() 为了解决兼容问题就需要做一个判断,需要两套代码 < div id ="small" > 解决FF和chrome上的bug只需要加上return false就可以了 </ div> </ div> </body > < script type ="text

老外可编辑div重新定位最后位置

自作多情 提交于 2019-12-26 04:02:17
You can try this code, it can auto focus in your last insert location. let p = document.getElementById('contenteditablediv') let s = window.getSelection() let r = document.createRange() r.setStart(p, p.childElementCount) r.setEnd(p, p.childElementCount) s.removeAllRanges() s.addRange(r) To build further on @Surmon answer. If you are looking to auto focus right after your last letter/number in the text instead of the last insertion location (last insertion location will move the cursor to a new line if the child nodes are enclosed in block type tags and not plain text) then apply this small

【重要重要】如何在div是contentEditable=true的里面获取光标的位置,并在光标位置处插入内容。焦点位置插入指定内容

笑着哭i 提交于 2019-12-26 02:58:21
为什么要在contentEditable=true的div里面获取光标呢?因为这篇文章https://blog.csdn.net/qq_33769914/article/details/85002918我们知道想在一个内容里面插入一个新的内容,如果这个新的内容是段html代码。最后显示的是有样式的。那么用input是无法实现的。 所以我们考虑用contentEditable=true的div。在这里面输入的html就没问题啦。 ———————————————— 版权声明:本文为CSDN博主「夏天想」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/qq_33769914/article/details/93596502 <!doctype html> <html> <head> <meta charset="utf-8"> <title>获取焦点位置并在焦点位置插入指定内容</title> </head> <body> <div contenteditable="true" class="fxAnswer" οnblur="getblur()"></div> <input type="text" id="text" placeholder="想要添加进去的内容"/> <button type

如何让DIV固定在页面的某个位置而不随着滚动条随意滚动

安稳与你 提交于 2019-12-25 10:55:21
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 这里稍微总结一下,那就是利用JavaScript脚本,从浏览器中获取各个关于位置的参数,然后将其计算后,定位在窗体的右下角。可以承认,这个方法确实是比较自然的想法,也是很常见的方法,但是这样的方法有以下几个缺点: 1、使用了大量的计算,每次滚动,都少不了一大堆的运算。 2、使用了JavaScript脚本,脚本这东西受到浏览器的限制,即便没有限制,也同样因为网页的下载模式问题,可能因为脚本下载未完成或者下载失败而致使脚本无法正确运行。 3、条条大路通罗马,但是看看那方块,当快速滚动滚动条的时候,会发现那个可爱的方块抖动地厉害。这也难怪,那么多的计算谁能受得了? 那有没有比较“平静”高效的表示方式呢?比如是否有一种用CSS的方式呢? 首先,我们将目光投向了CSS规范,我想很多人和我一样很快就想到了 position 属性,说到定位,我们很容易想到这个属性。这个属性一共有四个选项:static、relative、absolute、fixed( 详情请点击 )。很高兴,我们在阅读了相关的注释后,我们大概能看到fixed是比较符合我们的需求的: fixed: 位置被设置为 fixed 的元素,可定位于相对于浏览器窗口的指定坐标。此元素的位置可通过 " left " 、 " top " 、 " right " 以及 "

DIV浮动效果

﹥>﹥吖頭↗ 提交于 2019-12-25 01:18:55
Code 在web2.0之前,还不知道什么是ajax,也不喜欢div+css的布局方式,那时候网页布局就是一个个的大大小小的table嵌套起来,只要对属性设置合理,页面样式就中规中矩稳如泰山。不过这种布局对窗口尺寸的适应能力极弱,所以不得不每次考虑这次的网站做成1003还是780,而信息的呈现方式也极其死板,比如说在一个类似于list的信息汇总页面,如果用户想了解某一个item的详情,一般必须点击进入,造成一次页面刷新和等待。而现在的流行做法改变了,ajax使用户体验得到极大改善,现在面临上述的类似情形,完全可以采用另一种更加灵活的方式:生成呈现item详细内容甚至相关表单的浮动层,就像那个在《长尾理论》和《Foundations of Ajax》这两本亚马逊榜首图书中同时提到的著名网站Netflix一样,当用户把鼠标移到一个DVD海报图片上,带箭头的漂亮浮动层就在封面旁边生成了。最近我也试着看了看这种效果的基本实现方法,在这里做个笔记: 首先,这个浮动层其实是一个没有内容的div,为了控制div浮动的位置,需要将其style的position设置成absolute,为了使这个层浮动在页面其他元素之上,需要设置z-index为一个比较大的值,浮动层一开始应该是不可见的,即: < div id ="popup" style ="position:absolute; z-index