How do i add border in all four side of browser page no matter what browser, whatever resolution. Is there any such css or javascript code ?
+2
A:
Write the following lines in your CSS:
body {
border-width: 5px; /* or what you want */
border-style: solid;
border-color: red; /* or what you want */
/* or use the short form: */
border: 5px solid red;
}
elektronikLexikon
2010-09-12 18:03:32
Thanks , how do i always fit border-bottom to the bottom of the screen ?
sagarmatha
2010-09-12 18:30:48
Did you test it? Body has its margin and different size depending on content.
pepkin88
2010-09-12 18:32:36
yes it worked, but it looks odd when border bottom height changes. How can i fix border bottom always stays at bottom ?
sagarmatha
2010-09-12 18:43:52
A:
<body style="margin:0px;margin-right:2px;margin-bottom:2px">
<div style="width:100%;height:100%;border:1px solid red;margin-right:-2px;margin-bottom:-2px">
Stuff here
</div>
</body>
In my opinion it is better solution than elektronikLexikon's, because height is always 100%.
EDIT: Height is fine now.
EDIT2: I like jira's answer even more than mine ;)
PS. Request always the best answer, not that which meets only few requirements. I couldn't make it on time.
pepkin88
2010-09-12 19:09:19
+2
A:
If you want border around viewport you can try the following:
<html>
<head>
<style>
body {position: fixed; top:0; left: 0; bottom: -5px; right: -5px;
border: 5px solid red;}
</style>
</head>
<body>
</body>
</html>
Depending on what you want exactly even better might be to use something as YUI Layout Manager.
jira
2010-09-12 19:14:14
Nice one, I didn't consider setting left and right position at once would be correct. Even though `bottom: 0; right: 0;` looks better, distances to the edge would be equal.
pepkin88
2010-09-12 19:20:28