码迷,mamicode.com
首页 > Web开发 > 详细

[Web 前端] 020 css 定位之绑定定位

时间:2019-05-03 14:43:27      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:参考   效果   定位   20px   网页   alt   web   har   截图   

绑定定位

  • 少废话,上例子
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>test</title>
        <link rel="stylesheet" type="text/css" href="./static/CSS/test.css">
    </head>
    <body style="height:3000px"> <!-- 为了可以滚动页面 -->
        <div class="box">返回顶部</div>
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
    </body>
</html>
div{
    height: 500px;
    background: #edd094;
    border: 2px solid;
    box-sizing: border-box;
}
.box{
    width: 100px;
    height: 50px;
    text-align: center;
    line-height: 40px;
    background: cyan;
    /*绑定定位
        以浏览器窗口为参考进行定位
        主要用在:固定在头部的导航栏 返回顶部,网页的侧边栏菜单 */
    position: fixed;
    bottom: 20px;
    right: 20px;
}
  • 效果截图

技术图片

[Web 前端] 020 css 定位之绑定定位

标签:参考   效果   定位   20px   网页   alt   web   har   截图   

原文地址:https://www.cnblogs.com/yorkyu/p/10804491.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!