简体   繁体   English

浮动操作按钮不起作用?

[英]floating action button is not working?

The problem I'm having is that when am click on button it should be come to top and floated. 我遇到的问题是,当我单击按钮时,它应该位于顶部并浮动。 come to top is working but it not floated..can anyone suggest me for this problem...... 来到顶部正在工作,但没有浮动..有人可以建议我解决这个问题吗...

code like bellow 像下面的代码

<div class="create-course-info" id="scroll">
<a href="#" ><span class="count"><i class="fa fa-angle-up"></i></span>                                      
</a>
</div> 

css like bellow CSS像波纹管

.create-course-info {
    position: relative;
    min-height: 50px;
    margin-bottom: 30px;
    padding: 10px;
}
.create-course-info .count {
    display: inline-block;
    width: 50px;
    height: 50px;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;
    text-align: center;
    line-height: 44px;
    font-family: 'Lato', sans-serif;
    font-size: 24px;
    float: right;
    border: 3px solid #37abf2;
    background-color: #eee;
    color: #666;
}
.fa-angle-up:before {
    content: "\f106";
}

script code 脚本代码

<script type='text/javascript'>
    $(document).ready(function(){ 
        $(window).scroll(function(){ 
            if ($(this).scrollTop() > 100) { 
                $('#scroll').fadeIn(); 
            } else { 
                $('#scroll').fadeOut(); 
            } 
        }); 
        $('#scroll').click(function(){ 
            $("html, body").animate({ scrollTop: 0 }, 600); 
            return false; 
        }); 
    });
</script>

Set position of create-course-info to fixed . create-course-info位置设置为fixed

.create-course-info {
    position: fixed;
    min-height: 50px;
    margin-bottom: 30px;
    padding: 10px;
}

Fiddle 小提琴

No sure what you want to do with the float, but here is an JSFIDDLE example with your code and Position set to Fixed and an initial state of Display:none 不确定要对浮点数做什么,但是这是一个JSFIDDLE示例,您的代码和Position设置为Fixed ,初始状态为Display:none

JSFIDDLE JSFIDDLE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM