Blogger Information
Blog 6
fans 0
comment 0
visits 4147
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
编程实现用五个色块制作一个十字架实战-2018年8月16日
cousin的博客
Original
866 people have browsed it

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>十字架</title>

<style>

.box1{

width: 50px;

height: 50px;

background-color: red;

position: relative;/*设置相对位置*/

left: 50px;/*左移50px*/

}

.box2{

width: 50px;

height: 50px;

background-color: blue;

}

.box3{

width: 50px;

height: 50px;

background-color: black;

position: relative;/*设置相对位置*/

top: -50px;/*上移50px*/

left: 100px;/*左移100px*/

}

.box4{

width: 50px;

height: 50px;

background-color: yellow;

position: relative;/*设置相对位置*/

top: -100px;/*上移100px*/

left: 50px;/*左移50px*/

}

.box5{

width: 50px;

height: 50px;

background-color: green;

position: relative;/*设置相对位置*/

top: -100px;/*上移100px*/

left: 50px;/*左移50px*/

}

</style>

</head>

<body>

<div class="box1"></div>

<div class="box2"></div>

<div class="box3"></div>

<div class="box4"></div>

<div class="box5"></div>

<h3>总结:该十字架利用相对位置relative来进行位置的移动,最终组成一个十字架,相对位置relative是相对自身的位置,top上移距离,如50距离是top:-50px,而不是top:50px,这个是往下移动的距离,下跟左是正方向的距离,右跟上是负方向的距离</h3>

</body>

</html>


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post