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 height with relative position as child div with absolute position using css?
I'm trying to put a fixed divsion at the top of the page but when I scroll with FF, lines are lost
fixed position z-index not working
how to create adjustable gap between elements (div)
How to properly apply a css hack for IE11 transition misbehaviour
How do you make leaflet popup window full screen on small screens?
Fix a div to the bottom while scrolling with skrollr
Sticky Footer at bottom of PAGE, not just bottom of WINDOW
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

Categories

HOME
sonarqube
oracle12c
time-complexity
css3
pascal
sitecore
switch-statement
telegram-bot
hugo
limit
bookmarks
azure-container-service
sendgrid-api-v3
heap
github-enterprise
text-mining
spring-social
mongodb-csharp
job-scheduling
dimensional-modeling
video-editing
smartclient
enterprise-miner
blade
zxing
resourcebundle
gpio
amazon-quicksight
uitapgesturerecognizer
database-comparison
quickfixj
jett
gojs
yowsup
apiary.io
protein-database
print-css
congestion-control
show-hide
monkey-testing
snapchat
ovf
jquery-ui-draggable
reportservice2010
vugen
magic-draw
static-cast
libjpeg
java-websocket
cd-burning
usart
flex-monkey
ziparchive
flex4.6
lean
http-status-code-401
qiime
dynatree
oracle-spatial
lasso
sha512
rrule
public-html
showdialog
webmatrix-3
paw
verold
jquery-slider
fpdi
decoupling
jammer
jeromq
rolify
twisted.web
preload
extreme-programming
objectquery
infobright
google-maps-mobile
ikimagebrowserview
pylucene
xui
load-time
uideviceorientation
easyb
complex-event-processing

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