把图片放到要制作的网页中时,怎样确保图片与网页大小相当
- 提问者网友:爱唱彩虹
- 2021-05-23 07:11
- 五星知识达人网友:酒者煙囻
- 2021-05-23 07:35
用JS代码可以,不过不建议让背景图片随网页大小变化
脚本说明:
第一步:把如下代码加入<body>区域中
<script language="JavaScript">
<!--
function Is() {
var agent = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.ns = ((agent.indexOf('mozilla') != -1) &&
(agent.indexOf('spoofer') == -1) &&
(agent.indexOf('compatible') == -1) &&
(agent.indexOf('opera') == -1) &&
(agent.indexOf('webtv') == -1));
this.ns2 = (this.ns && (this.major == 2));
this.ns3 = (this.ns && (this.major == 3));
this.ns4 = (this.ns && (this.major == 4));
this.ns6 = (this.ns && (this.major >= 5));
this.ie = (agent.indexOf("msie") != -1);
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) &&
(agent.indexOf("msie 5.0") == -1));
this.ie5 = (this.ie && (this.major == 4) &&
(agent.indexOf("msie 5.0") != -1));
this.ieX = (this.ie && !this.ie3 && !this.ie4);
}
var is = new Is();
//-->
</script>
<script langauge="javascript">
if(is.ns4||is.ns6) {
available_width=innerWidth;
available_height=innerHeight;
} else if(is.ie4||is.ie5) {
available_width=document.body.clientWidth;
available_height=document.body.clientHeight;
}
if(is.ie4 ||is.ie5||is.ns6|| is.ns4) {
image1_width = (available_width*1.00);
image1_height = (available_height*1.00);
var image1 = '<img src=" http://img.alixixi.com/mylogo.gif" WIDTH="' + image1_width + '" HEIGHT="' + image1_height + '" onclick="javascript:window.open(this.src);" style="CURSOR: pointer" onload="return imgzoom(this,550)">';
document.write(image1);
}
</script>
第二步:把<body>中的内容改为:
<body onResize="history.go(0)">
- 1楼网友:神鬼未生
- 2021-05-23 13:01
请问太小是什么意思?
一般的网页的背景图片都比较小
- 2楼网友:有你哪都是故乡
- 2021-05-23 12:22
- 3楼网友:夜余生
- 2021-05-23 10:47
- 4楼网友:街头电车
- 2021-05-23 09:11
- 5楼网友:低血压的长颈鹿
- 2021-05-23 09:01
您是用DW制作吗?直接插入背景图片就可以了,它自动会铺满网页的页面的,如再不行可以QQ联络我哦