Reputation: 5
I'm having difficulty moving an entire div to the left but it doesn't seem to be working. Primarily getting the button to actually work with javascript is quite a pain since I'm trying to learn CSS over code that does work like PHP or JS.
left: 100%;
I tried using some sample code from another stackoverflow question and on button click to push the div left 100% but it doesn't seem to be working :/
And then I tried using an id:active but it didn't work for me.
Can anyone help me get some JS to activate the CSS, and code to add to the button to activate the JavaScript?
Any suggestions are welcome, also thanks in advance. Here is the code if anyone needs it:
Button:
<button class="btn btn-embossed btn-primary">Access Website</button>
Div Class:
<div class="wrapper">..</div>
(.. is representing etc, because its basically welcome text before the button)
Upvotes: 0
Views: 361
Reputation: 429
if you want to move a DOM element it should have an absolute positioning:
.wrapper { position: absolute; }
OR
<div class='wrapper' style='position:absolute;'></div>
then you can move the element with javascript:
// get the first element with class 'wrapper'
var element = document.getElementsByClassName('wrapper')[0];
// set the left position
element.style.left = '2px';
Upvotes: 1
Reputation: 48
There are many jQuery plugins that do what you want, and most come with extensive documentation on how to use them.
I'm still a little unclear what you want. Look at the demo for this plugin. Is it similar to what you were looking for?
Upvotes: 0