<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>欢迎来到HTML世界</title>
<link href="0001.css" rel="stylesheet"><!--获取的文件是style样式表-->
</head>
<body>
<div id="container"><!--div封装,id区块说明-->
<h1>我爱鱼C</h1>
<p>WWW.FishC.com - 让编程改变世界</p>
<a id="first_Js">传送门
</a>
</div>
<!--<script type="text/javascript"> 直接写在body
var first_Js = document.getElementById('first_Js');
/*alert(first_Js);测试*/
first_Js.onclick = function(e)
{
e.preventDefault();
first_Js.innerHTML = "穿越成功";
}
</script>
-->
<script src ="0001js.js"></script>>
</body>
</html>
/*<style type="text/css">指定CSS的样式定义*/
/*css文件*/
@charset"UTF-8";
body{
background: url(1.png)center center;/*图片加center center,就能保持一直显示中间位置,如果不加,当页面缩小到小于图片尺寸时,只能出现图片顶部、左侧的内容*/
background-size: cover;/*不会产生平铺的效果,只会一张图放大缩小*/
margin: 0;
padding: 0;/*潜规则,提高自主控制*/
position: relative;/*若设置containertop属性,container必须绝对定位,body相对定位*/
}
html,body{/*为了确保照片自适应屏幕显示,需要给body以及body的父级(html)设置height属性,使之充满全屏。*/
height: 100%; /* height如果不设置100%,就会出现重复
*/
color: #ffffff;
font-family:sans-serif;
}
#container{/*定义ID选择器必须添加#号*/
width: 100%;
text-align: center;/*文字居中*/
position: absolute;/*绝对定位*/
top: 50%;
transform: translateY(-50%);/*使container在Y轴方向上移动50%*/
}
h1{
font-size: 55px;
margin-bottom: 22px;/*控制行间距,h1标题与下面p之间的距离*/
}
p{
font-size: 22px;
margin-bottom:22px;
}
a{
font-size:33px;
background: #66B0A7;
color:#fff;
/*border: 5px double #ffffff;/*宽度。样式。颜色*/
border-radius: 10px;
padding: 10px 66px;/*上下两侧10px,左右两侧66px*/
text-decoration: none;/*定义无边框*/
}
/*</style>*/
var first_Js = document.getElementById('first_Js');
/*alert(first_Js);测试*/
first_Js.onclick = function(e)
{
e.preventDefault();
first_Js.innerHTML = "穿越成功";
}
|