Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML, CSS: How do I stretch an element up to the edge of the page?

Tags:

html

css

stretch

I have an absolutely positioned element with a background image that must appear as a small, horizontal strip reaching up to the edge of the browser window without needing a scrollbar. How could I do this?

like image 946
Hamster Avatar asked Dec 26 '10 19:12

Hamster


1 Answers

Set both left and right CSS properties to 0.

Kickoff example:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>SO question 4535198</title>
        <style>
            #strip {
                position: absolute;
                top: 0;
                left: 0;
                right: 0;
                height: 2px;
                background-image: url('some.png');
            }
        </style>
    </head>
    <body>
        <div id="strip"></div>
    </body>
</html>
like image 88
BalusC Avatar answered Oct 25 '22 01:10

BalusC