个人介绍主页制作简单的(html css js)

提出问题:

  1. 4个按钮,4个div,4个按钮控制控制div切换?(位置合适)
  2. 有一个div放4张图片?
  3. 制作个留言区?

解决问题:

4个div用position absolute; 使重叠一起(共同属性)
之后用z-index=1,使重叠位于上面(想让哪个div出现在最上层,
就加css属性z-index=1,其它的没有这个属性)通过javascript制作。

有一个div放4张图片:添加4个小盒子(div),使4张图片为4个小盒子的背景图

js(记住的一些):

获取元素方式:通过获取它的css标签 找到元素并定义变量:例子
var button=document.getElementsByClassName(‘btu’);//获取所有具有btu的css元素
也可以
var button=document.querySelector(’.btu’);//获得的只有第一个元素

<button class="button1 btu">个人介绍</button>
<button class="button2 btu">我的作品</button>

其它获取元素方式:
1.获取id属性
id=“btna”
var div=document.getElementById(‘btna’);
2.直接获得标签属性

<button></button>

var but=document.querySelector(‘button’);

查看显示元素属性
console.dir(元素变量);
console.dir(tu);
console.dir(button);

注册事件,一点击变量指定的元素,触发事件
button[0].addEventListener(‘click’,function(){

}

tu[i].className=‘tu’;
//给这个元素加css属性(但是之前给的css属性消失了)
可以
tu[0].className=‘tu front’; 多添加一个属性(具有两个css属性)

css代码:

.background{
position: relative;
width: 1920px;
height: 1080px;
background-image: url(../个人页面制作/2052882.jpg);
background-size: 100% 70%;
background-repeat: no-repeat;

}


button{
position: absolute;
width: 200px;
height: 50px;
background-color: chartreuse;
left: 400px;
}
.button1{
top: 150px;
background-color: #4cc7a8;
}
.button2{
background-color: #efd70c;
    top: 230px;
}
.button3{
    background-color: #f010ce;
    top: 290px;
    
}
.button4{
background-color: #e5254e;
    top: 350px;
}

.tu{

position: absolute;
width: 700px;
height: 500px;
background-color:white;
right: 600px;

top: 150px;

}




.one1{
position: absolute;
width: 300px;
height: 200px;
background-color: blue;
left: 30px;

background-image: url(../个人页面制作/2052461.jpg);
background-size: 100% 100%;
background-repeat: no-repeat;
}
.one2{
background-image: url(../个人页面制作/2052545.jpg);
    position: absolute;
width: 300px;
height: 200px;
background-color: blue;

left: 350px;
background-size: 100% 100%;
background-repeat: no-repeat;

}
.one3{
    background-image: url(../个人页面制作/2052563.jpg);
    position: absolute;
width: 300px;
height: 200px;
background-color: blue;
left: 30px;
top: 280px;


background-size: 100% 100%;
background-repeat: no-repeat;


}
.one4{
background-image: url(../个人页面制作/2052587.jpg);
    position: absolute;
width: 300px;
height: 200px;
background-color: blue;

left: 350px;
top: 280px;

background-size: 100% 100%;
background-repeat: no-repeat;

}



.two{

background-image: url(../个人页面制作/2052182.jpg);
    position: absolute;
   left: 30px;
width: 626px;
height: 370px;
background-color: blue;
background-size: 100% 100%;
background-repeat: no-repeat;


}

input{
    width: 277px;
position: absolute;
left: 200px;


}
textarea{ width: 277px;
position: absolute;
left: 200px;}




.four1{
    height: 40px;
top: 60px;
}

.four2{
    height: 210px;
top: 120px;
}
.four3{
    width: 277px;
position: absolute;
bottom: 100px;
left: 200px;
height: 43px;
background-color: #121b37;
color: white;

}

.front{

    z-index: 1;
}


html代码:

<div class="background">


<button class="button1 btu">个人介绍</button>
<button class="button2 btu">我的作品</button>
<button class="button3 btu">个人技巧</button>
<button class="button4 btu">在线留言</button>

<div class="three tu front">


<h3>我写此信应聘贵司公招聘的经理助理职位。 </h3>
<p>我很高兴地在招聘网站得知你们的招聘广告,并一直期望能有机会加盟贵司公</p>
<p>1、愿意吃苦受累,通过自己富有激情、积极主动的努力实现自身价值。作风优良、待人诚恳,人际关系良好,处事冷静稳健,能合理地统筹安排生活中的事务。具备较强的逻辑思维和判断能力,对事情认真负责,有很强的责任心和团队意识;自信、乐观,具有一定的创新意识和创造能力。</p>

  <p>  2、我是一个认真工作,认真钻研,勇于创新的人。能熟练运用电脑,掌握一定的office办公软件,与老师与同学保持着紧密的关系,乐于帮助同学解决学习与生活上的麻烦,善于总结归纳,善于沟通,有良好的敬业作风和团队合作精神。</p>
</div>
<div class=" tu  ">
<p>作品</p>

<div class="one1"></div>
<div class="one2"></div>
<div class="one3"></div>
<div class="one4"></div>





</div>
<div class=" tu">


<p>技能</p>
<p>拍出优美的照片</p>
<div class="two">



</div>



</div>

<div class=" tu">

<P>留言</P>
<input type="text" value="请输入你的姓名" class="four1">
<textarea name="" id="" cols="30" rows="10" class="four2">输入留言:</textarea>

<button class="four3">提交留言</button>


</div>




    </div>
var button=document.getElementsByClassName('btu');
var tu=document.getElementsByClassName('tu');
var i=0;



console.log(111);


console.dir(tu);
console.log(button);
button[0].addEventListener('click',function(){

for(var i=0;i<4;i++)
{

    tu[i].className='tu';
}

    tu[0].className='tu front';

})


button[1].addEventListener('click',function(){

for(var i=0;i<4;i++)
{

    tu[i].className='tu';
}

    tu[1].className='tu front';

})
button[2].addEventListener('click',function(){

for(var i=0;i<4;i++)
{

    tu[i].className='tu';
}

    tu[2].className='tu front';

})
button[3].addEventListener('click',function(){

for(var i=0;i<4;i++)
{

    tu[i].className='tu';
}

    tu[3].className='tu front';

})












    </script>

效果图:

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

  • 15
    点赞
  • 117
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

半浮名

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值