1、如何控制一段代码在网页上的上下高度??
放到一个div里,div的position:absolute,然后设置top或者bottom、left或者right、width、height,这样就能把这个div固定在某个位置了,透明的话就设置opacity,话说,其实都是css啦
2、写一个绝对定位1-2-1页面布局的代码
利用相对定位 绝对定位、浮动布局代码如下(直接复制以后代码即可):相对定位 绝对定位、浮动布局#container{ margin:0 auto; width:1000px; clear:both; position:relative;/*相对定位*/}#header{ margin:0 auto; width:1000px;height:100px; ...
3、如何用div实现页面上下部分固定,中间部分随滚动条移动而移动的代码?
代码详情如下,直接使用即可!
.content1{
overflow: hidden;
overflow-y:scroll;
SCROLLBAR-FACE-COLOR:#205e17;
SCROLLBAR-SHADOW-COLOR:#86ff92;
SCROLLBAR-SHADOW-COLOR:#86ff92;
SCROLLBAR-3DLIGHT-COLOR:#205e17;
SCROLLBAR-TRACK-COLOR:#205e17;
SCROLLBAR-DARKSHADOW-COLOR:#205e17;
SCROLLBAR-BASE-COLOR:#205e17;
SCROLLBAR-ARROW-COLOR:#86ff92;
height:700px;
width:748px;
}
中间的div就用下面的,样式是上面的。
<div class="content1">
<div>
4、求html按钮上下自由放的代码
放在哪个地方都可以,就是绝对定位了。用CSS属性position: absolute配合top和left两个属性(确定左上角坐标)来实现。但需注意,这个绝对是相对于上级元素来说的,要相对于整个页面随处可放,就要把它作为<html>的子元素。
我有一个用鼠标位置定位元素的html发给你参考一下:
<!doctype html>5、如何用div实现页面上下部分固定,中间部分随滚动条移动而移动的代码
1、头部定义一个div,固定高度,设置绝对定位(position:absolute),设置上边距(top:0);
2、底部定义一个div,固定高度,设置绝对定位(position:absolute),设置下边距(bottom:0);
3、中间定义一个div,设置滚动条自动( overflow: auto); 设置绝对定位(position:absolute),设置top和bottom,top的值等于头部div的高度,bottom的值等于底部div的高度
示例
<html>6、如图,网页设计,文字和表单上下对齐,请写出HTML代码,谢谢!
这个很简单,随便写,你可以参考下php中文网的资料,上面有例子的,html还是很简单的,我吧代码贴给你,你自己看下
<!DOCTYPE html>就完成效果了!
7、求 网页一侧上下漂浮图片代码?
<html>
<head>
<style type="text/css">
#floater {
position: absolute;
left: 500;
top: 146;
width: 125;
visibility: visible;
z-index: 10;
}</style>
<title>跟随屏幕移动的图片</title>
</head><body>
<div ID="floater" style="left: 0px; top: 0px">
<p align="center">
<img SRC="../../image/logo.jpg" border="0" width="85" height="55">
</div><script LANGUAGE="JavaScript">
self.onError=null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
<!-- STALKER CODE -->
function heartBeat() {
if(IE) { diffY = document.body.scrollTop; diffX = document.body.scrollLeft; }
if(NS) { diffY = self.pageYOffset; diffX = self.pageXOffset; }
if(diffY != lastScrollY) {
percent = .1 * (diffY - lastScrollY);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater.style.pixelTop += percent;
if(NS) document.floater.top += percent;
lastScrollY = lastScrollY + percent;
}
if(diffX != lastScrollX) {
percent = .1 * (diffX - lastScrollX);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater.style.pixelLeft += percent;
if(NS) document.floater.left += percent;
lastScrollX = lastScrollX + percent;
}
}
<!-- /STALKER CODE -->
<!-- DRAG DROP CODE -->
function checkFocus(x,y) {
stalkerx = document.floater.pageX;
stalkery = document.floater.pageY;
stalkerwidth = document.floater.clip.width;
stalkerheight = document.floater.clip.height;
if( (x > stalkerx && x < (stalkerx+stalkerwidth)) && (y > stalkery && y < (stalkery+stalkerheight))) return true;
else return false;
}
function grabIt(e) {
if(IE) {
whichIt = event.srcElement;
while (whichIt.id.indexOf("floater") == -1) {
whichIt = whichIt.parentElement;
if (whichIt == null) { return true; }
}
whichIt.style.pixelLeft = whichIt.offsetLeft;
whichIt.style.pixelTop = whichIt.offsetTop;
currentX = (event.clientX + document.body.scrollLeft);
currentY = (event.clientY + document.body.scrollTop);
} else {
window.captureEvents(Event.MOUSEMOVE);
if(checkFocus (e.pageX,e.pageY)) {
whichIt = document.floater;
StalkerTouchedX = e.pageX-document.floater.pageX;
StalkerTouchedY = e.pageY-document.floater.pageY;
}
}
return true;
}
function moveIt(e) {
if (whichIt == null) { return false; }
if(IE) {
newX = (event.clientX + document.body.scrollLeft);
newY = (event.clientY + document.body.scrollTop);
distanceX = (newX - currentX); distanceY = (newY - currentY);
currentX = newX; currentY = newY;
whichIt.style.pixelLeft += distanceX;
whichIt.style.pixelTop += distanceY;
if(whichIt.style.pixelTop < document.body.scrollTop) whichIt.style.pixelTop = document.body.scrollTop;
if(whichIt.style.pixelLeft < document.body.scrollLeft) whichIt.style.pixelLeft = document.body.scrollLeft;
if(whichIt.style.pixelLeft > document.body.offsetWidth - document.body.scrollLeft - whichIt.style.pixelWidth - 20) whichIt.style.pixelLeft = document.body.offsetWidth - whichIt.style.pixelWidth - 20;
if(whichIt.style.pixelTop > document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5) whichIt.style.pixelTop = document.body.offsetHeight + document.body.scrollTop - whichIt.style.pixelHeight - 5;
event.returnValue = false;
} else {
whichIt.moveTo(e.pageX-StalkerTouchedX,e.pageY-StalkerTouchedY);
if(whichIt.left < 0+self.pageXOffset) whichIt.left = 0+self.pageXOffset;
if(whichIt.top < 0+self.pageYOffset) whichIt.top = 0+self.pageYOffset;
if( (whichIt.left + whichIt.clip.width) >= (window.innerWidth+self.pageXOffset-17)) whichIt.left = ((window.innerWidth+self.pageXOffset)-whichIt.clip.width)-17;
if( (whichIt.top + whichIt.clip.height) >= (window.innerHeight+self.pageYOffset-17)) whichIt.top = ((window.innerHeight+self.pageYOffset)-whichIt.clip.height)-17;
return false;
}
return false;
}
function dropIt() {
whichIt = null;
if(NS) window.releaseEvents (Event.MOUSEMOVE);
return true;
}
<!-- DRAG DROP CODE -->
if(NS) {
window.captureEvents(Event.MOUSEUP|Event.MOUSEDOWN);
window.onmousedown = grabIt;
window.onmousemove = moveIt;
window.onmouseup = dropIt;
}
if(IE) {
document.onmousedown = grabIt;
document.onmousemove = moveIt;
document.onmouseup = dropIt;
}
if(NS || IE) action = window.setInterval("heartBeat()",1);
</script>
</body></html>
8、网页设计绝对定位的代码是什么?
p
9、怎么控制html元素的位置(上下左右)代码如下:
<!DOCTYPE html>
<html>
<head>
<title>MyHtml.html</title>
<script type="text/javascript">
var tmp=1;
function XX(){
var tab = document.getElementById("tab");
var span = document.createElement("span");
var tr = document.createElement("tr");
var select = document.createElement("select");
var textarea1 = document.createElement("textarea");
var textarea2 = document.createElement("textarea");
var textarea3 = document.createElement("textarea");
var textarea4 = document.createElement("textarea");
var inputDel = document.createElement("input");
select.add(new Option("css","cssEntryAddress"));
select.add(new Option("regex","regexEntryAddress"));
select.add(new Option("xpath","xpathEntryAddress"));
select.setAttribute("style", "width:80px;");
textarea1.setAttribute("placeholder", "范例:");
textarea1.setAttribute("style", "width:130px;");
textarea1.setAttribute("rows", "1");
textarea2.setAttribute("placeholder", "范例:");
textarea2.setAttribute("style", "width:155px;");
textarea2.setAttribute("rows", "1");
textarea3.setAttribute("placeholder", "范例:");
textarea3.setAttribute("style", "width:155px;");
textarea3.setAttribute("rows", "1");
textarea4.setAttribute("placeholder", "范例:");
textarea4.setAttribute("style", "width:155px;");
textarea4.setAttribute("rows", "1");
inputDel.setAttribute("type", "button");
inputDel.setAttribute("value", "删除");
inputDel.setAttribute("class", "btn btn-info");
inputDel.setAttribute("style", "width:50px;");
inputDel.setAttribute("onclick", "deltd(this);");
span.appendChild(select);
span.appendChild(textarea1);
span.appendChild(textarea2);
span.appendChild(textarea3);
span.appendChild(textarea4);
span.appendChild(inputDel);
tr.appendChild(span);
tab.appendChild(tr);
tmp++;
}
function deltd(a){
a.parentNode.parentNode.removeChild(a.parentNode);
}
</script>
</head>
<body>
<form action="">
<input type="button" onclick="XX();" id="add" value="增加行"/>
<table id="tab">
</table>
</form>
</body>
</html>
这是代码