h5的相对定位、绝对定位、固定定位以及案例练习

html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
        #right,#left,#center{
            float: left;
        }
        #left{
            width: 200px;
            height: 200px;
            background-color: yellow;
        }
        #center{
            width: 200px;
            height: 200px;
            background-color: #cccccc;
            /*position: relative;*/
            position: absolute;
            top: 20px;
            left: 20px;
            /*z-index 可以改变浮动的布局
              z-index可以在相对和绝对定位中使用*/
            z-index: -1;
        }
        #right{
            width: 200px;
            height: 200px;
            background-color: aquamarine;
        }
    style>
    <title>定位title>
head>
<body>





<div style="position: relative;top: 50px;left: 100px">
    <div>
        <div id="left">div>
        <div id="center">div>
        <div id="right">div>
    div>
div>
body>
html>
书签式界面的方法线、点、方框全是图片
html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
        .biao{
            position: relative;
            height: 700px;
            width: 1011px;
            background-color:darkgrey;
        }
        .shu{
            position: absolute;
            width: 1px;
            height: 658px;
            background-image: url("../../img/f1_line.png");
            left: 505px;
            top: 21px;
        }
        .dian1{
            background-image: url("../../img/f1_dot.png");
            position: absolute;
            width: 18px;
            height: 18px;
            top: 20px;
            left: -8.5px;
        }
        .tu1{
            background-image: url("../../img/f1_2016.png");
            position: absolute;
            width: 480px;
            height: 167px;
            left: -481px;
            top: -16px;

        }
        .dian2 {
            background-image: url("../../img/f1_dot.png");
            position: absolute;
            width: 18px;
            height: 18px;
            top: 60px;
            left: -8.5px;
        }
        .tu2{
            background-image: url("../../img/f1_2015.png");
            position: absolute;
            width: 480px;
            height: 167px;
            left:18px;
            top: -15px;

        }
        .dian3{
            background-image: url("../../img/f1_dot.png");
            position: absolute;
            width: 18px;
            height: 18px;
            top: 220px;
            left: -8.5px;
        }
        .tu3{
            background-image: url("../../img/f1_2014.png");
            position: absolute;
            width: 480px;
            height: 167px;
            left: -481px;
            top: -16px;

        }
        .dian4{
            background-image: url("../../img/f1_dot.png");
            position: absolute;
            width: 18px;
            height: 18px;
            top: 260px;
            left: -8.5px;
        }
        .tu4{
            background-image: url("../../img/f1_2013.png");
            position: absolute;
            width: 480px;
            height: 167px;
            left:18px;
            top: -15px;

        }
        .dian5{
            background-image: url("../../img/f1_dot.png");
            position: absolute;
            width: 18px;
            height: 18px;
            top: 420px;
            left: -8.5px;
        }
        .tu5{
            background-image: url("../../img/f1_2012.png");
            position: absolute;
            width: 480px;
            height: 167px;
            left: -481px;
            top: -16px;

        }
        .dian6{
            background-image: url("../../img/f1_dot.png");
            position: absolute;
            width: 18px;
            height: 18px;
            top: 460px;
            left: -8.5px;
        }
        .tu6{
            background-image: url("../../img/f1_2011.png");
            position: absolute;
            width: 480px;
            height: 167px;
            left:18px;
            top: -15px;

        }
    style>
    <title>书签title>
head>
<body>
<div class="biao">
    <div class="shu">
        <div class="dian1">
            <div class="tu1">div>
        div>
        <div class="dian2">
            <div class="tu2">div>
        div>
        <div class="dian3">
            <div class="tu3">div>
        div>
        <div class="dian4">
            <div class="tu4">div>
        div>
        <div class="dian5">
            <div class="tu5">div>
        div>
        <div class="dian6">
            <div class="tu6">div>
        div>
    div>
div>
body>
html>
固定定位的运用
html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
        #back{
            width: 150px;
            background-color: #4d2e83;
            height: 50px;
            text-align: center;
            line-height: 50px;
            position: fixed;
            bottom: 50px;
            right: 50px;
            /*z-index 一般设置为一个极大的数值 数字越大越在前*/
            z-index: 1000;

        }
    style>
    <title>固定定位title>
head>
<body>
<div style="height: 2000px">
    <div id="back">
        返回i页面顶部
    div>
div>
body>
html>

你可能感兴趣的:(HTML5)