css-position


Lightweight Javascript Responsive Positioning Library


I am looking for a responsive positioning library for easily placing many elements in different positions on a HTML slide. Sometimes elements will need horizontal or vertical alignment, generally alignment needs to be relative to another element,
Sometimes I want alignment to be say 30px from the left of a panel or positioned 25% from the panel bottom line.
I need a little more then just vertical centering, we need flexible positioning of multiple items, so that they stay proportionally relative to either parent or sibling elements and for it work inside of a responsive container so that it can be viewed on mobile phone or desktop
One of my team members has written some code to position various elements in a responsive slideshow, the slideshow works on different devices.
function CalculatePosition(slide) {
var body = $(slide).find('.bodySection');
var playBtn = $(slide).find('.playButton');
var skipBtn = $(slide).find('.skipButton');
var videoContainer = $(slide).find('.video-container');
var ytPlayer = $(slide).find('#ytplayer');
var middle = $(slide).find('.middle');
if (playBtn.length>0)
$(playBtn).css({ marginTop: ($(body).height() - $(playBtn).height()) / 2 + "px", marginLeft: "-" + $(playBtn).width() / 2 + "px" });
if (videoContainer > 0)
$(videoContainer).css({ marginTop: ($(window).height() - $(ytPlayer).height()) / 2 + "px" });
if (skipBtn > 0)
$(skipBtn).css({ top: $(ytPlayer).height() / 2 + "px", marginTop: "-" + $(skipBtn).height() / 2 + "px" });
if (middle > 0)
$(middle).css({ paddingTop: ($(body).height() - $(middle).height()) / 2 + "px" });
}
I have looked around for a library that would make this a lot cleaner?
I would be interested in either a lightweight library that does something like this.
$(playBtn).verticalCenterTo($(body));
// or
$(body).verticalCenter($(playBtn));
or a library that achieves the same thing using attribute notation
<div class='bodySection'>
<span class='playButton' align-relative-to='bodySection' align-type='vertical-center' />
<span class='stopButton' align-relative-to='playButton' align-position='right 20px' />
</div>
If you only need vertical positioning why not use a CSS only solution such as the display: table-cell technique descfibed here: http://www.vanseodesign.com/blog/demo/vertical-centering/table-cell.php
If you need to center with respect to different parents you can use class switching to get the desired effect. This is much faster than calculating it using JS.
Not sure if this does everything you need. Leave a comment if I misuderstood your question.

Related Links

How to set div absolute position from the parent div
Polymer paper-fab with position:fixed behaves strangely when used with core-list that has a scrollTarget
What is the use of “static” positioning in CSS?
CSS: fixed position
Style sheet positioning won't keep everything in place
Div on top 100%
CSS float image align
google sites html box tool css postion absolute
Manual Positioning of Shareaholic ShareBar Plugin
Div position (margin:auto)
Removing or Hiding Blank Space Left by Relative Positioning
Lightweight Javascript Responsive Positioning Library
Bootstrap 3.0 : Fixed column
space under footer on large screen resolution
Lightbox 2.6 positioning
how to fixed position of a div for all screen resolutions

Categories

HOME
notepad++
microsoftgraph
twitter-bootstrap-3
adal
jpa
angular-formly
powerpoint
battery
sh
solaris
shiro
pdfbox
nsbundle
tail
regular-language
polling
tvos
android-json
nstableheaderview
lanczos
character
drop-down-menu
fhir
distribution
appcelerator-studio
mautic
php-5.6
spring-social
comsol
gruntfile
null-pointer
intershop
html5-appcache
delphi-xe5
undertow
springfox
href
xunit
moses
gpio
pylons
intersystems-cache
genexus-sd
gitlab-api
fstream
spring-security4
getpixel
hibernate-search
sql-delete
graphhopper
verifiable-c
metaprogramming
hackintosh
signals-slots
apache-stanbol
skylink
datacachefactory
wmp
smoothstate.js
magento-2.0.7
jquery-ui-draggable
yii2-user
git-flow
ngmaterial
quicktime
flac
trigger.io
offline.js
py2neo
jtree
rocks
docpad
neon
installshield-2010
tooleap
dimension
deep
turbo-prolog
pushbots
exim4
themoviedb-api
batik
liquid-layout
kubuntu
apache-spark-1.3
showdialog
spy++
webfinger
paw
verold
codeplex
live555
grails-plugin-rabbitmq
dct
square-bracket
clickbank
getopt
notorm
ie8-compatibility-mode
flex++
redis-py
panda3d
adobe-media-server
box2d-iphone
relative
fsevents
uideviceorientation
non-clustered-index
office-2007
binomial-heap
lxr
data-mapping
purepdf
google-wave
entitykey
business-model

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App