muyral
muyral

Reputation: 35

fixed bottom right but left top will be in the same axis

I want to make a div which is fixed on the bottom and right but top margin and left margin will always be 100px from the browser! It is very weird I know but I coulndt do it. Maybe it needs a javascript? or can I make it with css?

Upvotes: 3

Views: 69

Answers (2)

Explosion Pills
Explosion Pills

Reputation: 191819

Media queries. Learn to use and love them.

@media all and (max-width: 600px) {
    div {
        left: 0;
        margin-left: 100px;
    }
}
@media all and (max-height: 300px) {
    div {
        top: 0;
        margin-top: 100px;
    }
}

http://jsfiddle.net/L35cE/

Upvotes: 1

Daniel Imms
Daniel Imms

Reputation: 50269

Here is a solution, just set left and top to the margin you need.

jsFiddle

JS

<div class="fixed"></div>

CSS

.fixed {
    position:fixed;
    left:100px;
    top:100px;
    right:0;
    bottom:0;
    background-color:#F00;
}

Upvotes: 2

Related Questions