EasilyBaffled
EasilyBaffled

Reputation: 3882

Get element to stick to bottom of the screen

I am trying inject an html element, with a chrome extension's content script. I want the element to overlay on a page, and stick to the bottom of the screen, like the count down bar is here. Most questions like this are really asking to stick the element to the bottom of the page itself, but I would like to have the element constantly visible and over the rest of the page. So how can I get it to stick to the bottom of the screen?

CSS:

  /*----------------*/
 /*----Main Page---*/
/*---------- -----*/
.t_inject_container {
    position:absolute;
    bottom:0px;
    left:0px;
    z-index: 999;
    background-color:grey;
    -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
    -moz-box-sizing: border-box;    /* Firefox, other Gecko */
    box-sizing: border-box; 
}
.menu {
    background-color:lightblue;
    border-radius:5px;
}
.t_intect_button {
    background-color:blue;
    display:block;
    height: 50px;
    width: 50px;
    margin: 5px;
    font-size: 20px;
    color: white;
    border: 0px;
    border-radius:7px;
    -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
    -moz-box-sizing: border-box;    /* Firefox, other Gecko */
    box-sizing: border-box; 
    border-radius:5px;
}

 /*-----------------*/
 /*Timeline Element*/
/*----------------*/
.timeline_element {
    background-color:red;
    border-radius:5px;

}
.t_text_area {
    height: 50px;
    width: 100px;
}

JS:

$(function(){
    //$(".add_button").click(add_timeline_element);

    function add_timeline_element(){
        var text_input = $('<input />', {
            type: "text",
            class: "t_text_area"
        });
        var button = $('<button />', {
            text: '-',
            class: "t_intect_button",
            click: function() {$(this).parent().remove();}
        });
        var timeline_element = $('<td />', {
            class: "timeline_element"
        });
        timeline_element.append(button);
        timeline_element.append(text_input);
        $(".t_inject_row").append(timeline_element);
    }

    function create_twitter_bar(){
        var table_container = $("<table />", {
            class: "t_inject_container"
        });
            var row = $("<tr />", {
                        class: "t_inject_row"
                        });
                var menu = $("<td />", {
                    class: "menu"
                });
                    var add_element_button = $("<button />", {
                        text: '+',
                        class: "add_button t_intect_button",
                        click: function() {add_timeline_element();}
                    });
                    var minimize_button = $("<button />", {
                        text: 'm',
                        class: "minimize_button t_intect_button"
                    });
                    menu.append(add_element_button);
                    menu.append(minimize_button);
            row.append(menu);
        table_container.append(row);
        $("body").append(table_container);
    }

    create_twitter_bar();
});

Upvotes: 2

Views: 1196

Answers (1)

Magesh Kumaar
Magesh Kumaar

Reputation: 1467

lets say that you have a <div> called footer !

HTML:

<div id="footer">
</div>

CSS:

#footer{
     position:fixed;  /*Setting up the position*/
     bottom:0;   /*Just Stay at the bottom*/
     width:100%;   /*Cover the whole screen's width or the parent element's width*/
}

Upvotes: 5

Related Questions