in Search

Blog Day Afternoon

Take a walk on the mild side.

Always Visible DIV Tags

It is very easy to make a DIV tag which stays visible on a web page even if the page is scrolled up or down or left or right. There is an ASP.Net AJAX Toolkit control called "AlwaysVisible", but anyone can do it with simple HTML. All that is required is a position:fixed attribute in the div tag's style. To place the div tag in a particular position on the page, you can add attributes of top, left, right, and bottom. If you don't want to display your div tag in a corner, it is still easy to place it more towards the middle; it just takes a little extra coding. You would still use the top or bottom placement, but on your left field you would use a value of 50% instead of a number of pixels. If you don't want it displayed smack dab in the middle of the page which would likely hide text, you can use a negative number of pixels in the margin-left field to move it off to the left, or a positive number of pixels to move it off to the right.

position:fixed
top:10px
left:10px
position:fixed
top:10px
right:10px
position:fixed
bottom:10px
left:10px
position:fixed
bottom:10px
right:10px
position:fixed
top:300px
left:50%
margin-left:-614px
position:fixed
top:300px
left:50%
margin-left:478px
Published Dec 30 2009, 03:51 PM by Blogette
Filed under: ,
Add to Bloglines Add to Del.icio.us Add to digg Add to Facebook Add to Google Bookmarks Add to Newsvine Add to reddit Add to Stumble Upon Add to Shoutwire Add to Squidoo Add to Technorati Add to Yahoo My Web

Comments

No Comments

Leave a Comment

You must log in first to post a comment. Click here to log in.

Not a member? Click here to sign up today!