Uutiset:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu
Advertisement:

Controlling where on the page the "new" link lands

Aloittaja bahgheera, marraskuu 29, 2013, 03:07:00 IP

« edellinen - seuraava »

bahgheera

Hi folks, here's my question of the day. I have changed my navigation around so that the site header and the menu bar are in fixed div's at the top, and the site scrolls underneath. This looks fantastic, but I've run into a snag - when you click the new button, or when you go to a message id#, the top of the message is aligned with the top of the browser - that is, the viewport. So the new message is always partially hidden underneath the header and nav bar. I've searched the forum and the web, I've looked through the function database and found where the link is generated. It's not like a simple anchor link though - if it were, I believe I'd have this in the bag. I have no idea what bit of programming is lining the message with the top of the viewport. Any insight on this? Thanks!

Website is http://www.theflipsideforum.com

Arantor

It is a simple enough link, the nav either points to an anchor of #msgXXXX or to #new.

Both of these are set in Display.template.php, both assigned inside a message's divs and so on and you can't exactly move them too far above the divs without there being problems down the line.

The template is set up to apply the same markup to each message.
Holder of controversial views, all of which my own.


bahgheera

Thanks Arantor. I guess what I'm asking is how do I add about 100px to the top of the screen so that the message will be visible when the page loads? I thought if I could target the <a> I could add padding of 100px and margin of -100px, to force it into place. But it's not happening, not with what I'm doing anyway. I'll keep plugging away on this. Thanks again.

Arantor

Nope, that's not how it works.

The browser is the one responsible for moving to anchors, not SMF. SMF just says 'go to the bit of the page marked #new' and makes sure that there's a bit defined to be #new at the start of the message in question and the browser does the rest.

There isn't a particularly good way of doing it (which is why floating navigation generally kind of sucks for usability), but http://nicolasgallagher.com/jump-links-and-viewport-positioning/demo/ does outline possible options which all have drawbacks.
Holder of controversial views, all of which my own.


bahgheera

Ah, thanks - that's exactly what I needed to know. I thought that smf must have some mechanism for placing the message vertically.

Advertisement: