Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align div to top right corner of screen regardless of resolution? [closed]

Tags:

javascript

css

This is in regards to the following page: http://kinkarso.com/rayku/slider.html

I'm looking to position the box to the top right corner of the screen, but currently if the screen resolution is different, it doesn't stay to the very right. Any ideas?

Thanks!

like image 466
Donny Avatar asked Dec 13 '22 06:12

Donny


1 Answers

No need for javascript, use CSS instead

Set position to fixed and add additional properties:

#tutors-popup {

    /* fixed within viewport */
    position: fixed;

    /* set position */
    top: 20px;
    right: 30px;

    /* must have dimension */
    width: 100px;
    height: 200px;
}

You will also realise you don't need the inner div...

If you don't like fixed alignment from the right margin, you can set right using % dimension as well. This will then set it differently depending on screen width (or resolution you're referring to).

like image 119
Robert Koritnik Avatar answered Feb 01 '23 23:02

Robert Koritnik