8

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?

Hamster
  • 2,962
  • 7
  • 27
  • 38

2 Answers2

9

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>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

Try this:

<style type="text/css">
.hrBar
{
        background-image: url('<YOUR_IMAGE_PATH>');
        background-repeat: repeat-x;
        height: 1px; // Or the Height of your Image
        position: absolute;
}
</style>
<div class="hrBar">
</div>
Chandu
  • 81,493
  • 19
  • 133
  • 134