• fixed布局居中


    fixed布局居中

    一、总结

    一句话总结:

    设置好【宽高】,然后设置【margin为auto】,位置的上下左右都设置为0就是上下左右居中了
    /*如果文档宽度小于 800 像素则修改:*/
    @media screen and (max- 800px) {
        #question_backend_btn_group{
            position:fixed;
            margin:auto;
            left:0;
            right:0;
            top:0;
            bottom:0;
            width:340px;
            height:60px;
        }
    }

    1、fixed布局左右居中实例?

    设置好宽高,然后设置margin为auto,【位置的左右都设置为0】就是左右居中了
    相对于fixed布局上下左右居中,如果只需要左右居中,那么把 【bottom:0; 或者 top:0; 删掉】即可
    #question_backend_btn_group{
        position:fixed;
        margin:auto;
        left:0;
        right:0;
        bottom:60px;
        width:340px;
        height:60px;
    }

    二、fixed布局居中

    1、上下左右都居中

    #question_backend_btn_group{
        position:fixed;
        margin:auto;
        left:0;
        right:0;
        top:0;
        bottom:0;
        width:340px;
        height:60px;
    }

    2、上下或左右居中

    如果只需要左右居中,那么把 bottom:0; 或者 top:0; 删掉即可
    如果只需要上下居中,那么把 left:0; 或者 right:0; 即可

    比如左右居中

    #question_backend_btn_group{
        position:fixed;
        margin:auto;
        left:0;
        right:0;
        bottom:60px;
        width:340px;
        height:60px;
    }

    html代码

    <div id="question_backend_btn_group" class="text-center">
        <button @click="previous_question_click" type="button" :class="['btn','btn-warning',{'disabled':is_left_btn_disabled(perQuestion.question_num)}]">
            <i class="fa fa-fw fa-angle-double-left"></i>
        </button>
        <!--question_right_state="-1" 表示没做-->
        <!--question_right_state="0" 表示做错-->
        <!--question_right_state="1" 表示作对-->
        <button style="position: relative;" type="button"  class="btn btn-warning submit_question">
            <span>提交</span>
            <div style="position:absolute;right: 0;top: 0;">
                <span style="min-font-size: 8px;font-size: 8px;"><b>1</b></span>
            </div>
        </button>
        <button type="button" class="btn btn-warning ">
            <i class="fa fa-fw fa-repeat"></i>
        </button>
        <button type="button"  class="btn btn-warning question_collect">
            <div class="collected"  style="color: red;">
                <i class="fa fa-fw fa-heart"></i>
            </div>
            <div class="uncollected" >
                <i class="fa fa-fw fa-heart-o"></i>
            </div>
        </button>
        <button type="button"  class="btn btn-warning btn-sm question_report" >
            <i class="fa fa-fw fa-file-text"></i>
        </button>
    
        <button @click="next_question_click" type="button" :class="['btn','btn-warning',{'disabled':is_right_btn_disabled(perQuestion.question_num)}]">
            <i class="fa fa-fw fa-angle-double-right"></i>
        </button>
    </div>
     
    我的旨在学过的东西不再忘记(主要使用艾宾浩斯遗忘曲线算法及其它智能学习复习算法)的偏公益性质的完全免费的编程视频学习网站: fanrenyi.com;有各种前端、后端、算法、大数据、人工智能等课程。
    博主25岁,前端后端算法大数据人工智能都有兴趣。
    大家有啥都可以加博主联系方式(qq404006308,微信fan404006308)互相交流。工作、生活、心境,可以互相启迪。
    聊技术,交朋友,修心境,qq404006308,微信fan404006308
    26岁,真心找女朋友,非诚勿扰,微信fan404006308,qq404006308
    人工智能群:939687837

    作者相关推荐

  • 相关阅读:
    如何做一个富文本编辑器
    chrome插件开发示例
    使用github Pages和Jekyll搭建一个Blog
    使用JavaScript制作简单的动画
    JQuery模拟七------利用extend包装ajax实现
    JQuery模拟六------jQuery处理事件简化版
    JQuery模拟五------实现属性set&get和CSS set&get
    JQuery模拟四------把用到Sizzle的地方先用CSS3选择器实现
    JQuery模拟三------利用extend函数扩展jQuery自身的方法和浏览器判断
    JQuery模拟二------添加extend函数和简单选择器
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/14333931.html
Copyright © 2020-2023  润新知