简体   繁体   中英

A text at bottom right of the window using Javascript

How I can replace a text at the bottom right of the window (not the page) and that text will follow the corner of the window (in other words, it will stay at the corner of the window). It will be a "share" link, I want it to be seen always.

You could use CSS's attribute position: fixed and then use bottom and right values to have it in the bottom right corner. (won't work in IE - needs some hacks)

yeah, as others have mentioned:

#share {
  display: none;
  position: fixed;
  bottom: 0px;
  left: 0px;
  width: 100%;
  z-index: 100;
}

<div id="share">[sharing links]</div>

you could do:

$(document).ready(function() {
  $('#share').fadeIn('slow');
});

this is just like huffingtonpost.com or basicallymoney.com.

If I understand correctly, it's not javascript that you need, just basic css.

You want to position a bar at bottom of the window, that would stay there, even if you scroll down/up?

CSS:

.bottom {
position: fixed;
bottom: 0;
} 

HTML:

<p class="bottom">Text, that you wan't to put at the bottom.</p>

Obviously it's a good idea to add backgroundcolor to the p.bottom, as well as some top-margin or top-padding, but it's just the general idea.

Test it on older IE however, because it may not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM