设为首页 加入收藏

TOP

前端学习日记之HTML、CSS 简单总结(七)
2019-09-03 03:32:36 】 浏览:185
Tags:前端 学习 日记 HTML CSS 简单 总结
ent=""> <style> *{ margin: 0; padding: 0; } .header { height: 50px; background: rgba(0,0,0,0.80); } .nav { width: 980px; height: 50px; margin: 0 auto; color: #fff; } .content{ width: 980px; height: 425px; margin-right: auto; margin-left: auto; overflow: hidden; border-bottom: 1px solid black ; } .left { width: 645px; height: 425px; background-color: yellow; float: left; } .right { width: 310px; height: 425px; background-color: pink; float: right; } .wrap980{ width: 980px; margin: 0 auto; height: 200px; background-color: green; } body{ min-width: 980px; } </style> </head> <body> <div class="header"> <div class="nav">This is NAV</div> </div> <div class="main"> <div class="content"> <div class="left"></div> <div class="right"></div> </div> </div> <div class="footer"> <div class="wrap980"></div> </div> </body> </html>

11. 定位

1> relative相对定位
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>Examples</title>
        <meta name="description" content="">
        <meta name="keywords" content="">
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            .box1 {
                width: 150px;
                height: 150px;
                background: black;

            }
            .box2 {
                width: 50px;
                height: 50px;
                background-color: red; 
                position: relative; 
            }
        </style>
    </head>
<body>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box1"></div>
</body>
</html>

  • 随心所欲将元素摆放任意位置,并且不影响别的元素的位置。
  • 只要用了定位,且值不为static时,都拥有四个样式:top、left、bottom、right,来调整元素的位置,
  • 移动后元素仍然占据原来的位置
  • 相对与元素父类元素定位进行平移
2> absolute绝对定位
  • 不占据任何空间,比浮动飘得还要高
  • 会覆盖浮动,但不会像浮动一样从左到右排列,而是发生重叠现象
  • 相对于该元素的父类元素的非static定位进行移动,若父类元素没有专门定位,则向上参考父类的父类的非static定位。。。
3> fixed固定定位
  • 不占据任何空间
  • 只以浏览器窗口为参考点进行移动
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>fix定位之右下角按钮固定</title>
        <meta name="description" content="">
        <meta name="keywords" content="">
        <style>
            * {
                margin: 0;
                padding: 0;
            }
            .right {
                width: 560px;
                height: 400px;
                background: pink;
                float: left;
            }
            .left {
                width: 250px;
                height: 400px;
                background: green;
                float: right; 
            }
            .warp {
                overflow: hidden;
                width: 825px;
                margin-top: 50px;
                margin-right: auto;
                margin-left: auto;
                
            }
            body {
                height: 2000px;
            }
            .f-box {
                width: 70px;
                height: 80px;
                background: skyblue;
                position: fixed; 
                left: 50%; /* 内容以浏览器中心为参照物*/
                margin-left: 432px; /*内容的左外边距*/
                bottom: 200px; /*内容距参照物底部距离 */
                font-size: 42px; /* 文字大小*/
                color: white; /*文字颜色*/
                cursor: pointer; /* 鼠标小手指 */
                text-align: center; /* 文字对齐方式实现文字上下居中 */
                line-height: 80px;  /* 行间距实现文字水平居中 */
                }
        </style>
    </head>
<body>
    <div clas
首页 上一页 4 5 6 7 8 9 10 下一页 尾页 7/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇sublime text3格式化html,css,js.. 下一篇ife2018 零基础学院 day 4

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目