How to implement a drag and swap effect in CSS and JS [closed]
Tags: javascript,css,position
Problem :
All:
Right now, say I have 4 DIV elements on the page, what I want to implement is drag a one DIV and move to other DIV then they can swap position just like IPHONE, when you hold the icon for a little while, all the icons turn into position edit mode, you can move icon around the screen and located to certain grid position and according icon can swap with it.
Could anyone show me an example for this?
Thanks
Solution :
Jquery UI makes this trivial:
https://jqueryui.com/draggable/#sortable
http://jqueryui.com/sortable/#default
The link also shows an example of how to use it.
CSS Howto..
/packages/meteor/package.js defined that .css files should be bundled. However, taking a close look at docs.meteor.com, we can find this information: CSS files work just the same: the client will get...
Give transparent border and change border-color on hover .screenshots img { border:5px solid transparent; } .screenshots img:hover { border-color:#06C; } Updated fiddle here....
For Firefox, one fix for the jumping scrolling behavior is to change the location hash to one that doesn't exist in the document. Changing your code to: $(document).ready(function () {...
So a real quick fix would be to apply an overflow of hidden to your html/body (you'll also need to define the height and width like this): html, body{ width:100%;...
There is an easy way to reach it. Just copy the <figure>...</figure> and append it after </figure>. And remember let the keyframes 0% seems like 100%. Maybe you can use...
I would add a "list target" div that you clear each time: Add this to your html at the bottom where you are wanting your items to appear. The nice...
If you are saying about the browser defaults than look at CSS reset stylesheets, they are all over the web, those stylesheets reset each elements properties to a standardized value....
the main function that can help you do hardware accelerated animations using HTML5/css/javascript is the -webkit-transform: translate3d css rule that translates the slides’ horizontal (x) position to the left or...
I always use pseudo elements :before and :after for changing the appearance of check boxes and radio buttons. its works like a charm. it's pure css. Your Background and border...
i found the answer. Actually its not a good practice unless and until you want a different a page in your web application which has totally different views from other...
Use none, inherit or initial to unset it. @media only screen and (min-width: 941px){ #slogan { font-size: 24px; position: absolute; min-width: 810px; text-align: right; margin-left:none; margin-right:none; } } ...
Add overflow:hidden for your dd elements (that keeps them from flowing underneath the floated dt), and remove the margin for li:first-child: http://jsfiddle.net/CBroe/E3QW2/3/...
You could ngIf to controller the completion of request and use that condition to render the UI. here is a sample on your component private isLoading = true ; private...
UPDATED Even better - use the <ul> as the identifier and go that route: <ul id="mainMenu"> <li id="mainSuit"><a onclick="mainSuit()" href="javascript: void(0)">Suit</a></li> </ul> <ul id="suitMenu"> <li id="suitLoadout"><a>Loadout</a></li> <li...
Out puts the follwing kind of html. Make sure to wrap it with ul like this <ul class="main-nav"><?php wp_list_pages(); ?></ul> This is the typical output. <li class="pagenav">Pages <ul> <li...
I think the problem is that the styles from jQuery UI are in PX while the rest are in %. You usually run into problems when you combine that. Try...
updated with shape and border-colors div { margin-top:1em;; text-align: center; padding: 0.5em; border-top:1px solid lightgray; background: linear-gradient(to bottom, #ECECEC 50%, lightgray 50%, lightgray 51%, transparent 52%); } img { position:...
Because you need the svg to be embedded as an actual SVG so your CSS applies to it, you could use a little utility script like this: function replaceSVGS(elements){ if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image",...
Ultimately, your granularity is 1 physical pixel (well technically the sub-pixel in modern browsers, but I will ignore that for purposes of this discussion). You can have different calculated pixel...
Based on @GeekyMonkey's answer, I wrote this little snipped you can put somewhere in your less file: .debug(@var) { &:after { content: "@{var}"; font-size: 20px; background-color: #fff; border: 1px solid...
When you tried adding !important, you added it to: #trSalesTotal Instead of: #trSalesTotal td So give this a shot: #trSalesTotal td { border-top: 2px solid #a9a9a9 !important; border-left: 2px solid...
recently I have come across such problems, lucily I found the key point. You just need to add a simple line of code into the Css style sheet, to change...
For this task, I would use 2 divs and have the circle with a z-index value so that it will overlap the rectangle div. Make your border-radius size fairly large...
This is not possible, as it does not seem all that sensible in the first place (applying a hover for example to an element where the default style is already...
Specifically, you aren't removing the class of "expanded" when you stop hovering on your "ul ul". You're actually adding it again, which I guess is an unintended mistake!
Using comments from @LowerClassOverflowian, @srekoble and @AndreiVolgin, I came up with this solution: var newDiv = $('<div></div>') .text(lines[i]) .css({ 'margin-left':(underscoreCount * 5) + 'px' }); $('#div-text').append(newDiv); Where underscoreCount is the...
Simply use a css psuedo selector: .wrapper:hover { /* whatever styles you want */ } As far as I know, you can't put a pseudo selector on the body. You...
There is a css property named text-overflow which accomplishes this. If you use it in conjunction with white-space: nowrap, you can achieve what you're trying to do. Here's a demo...
You're forgetting to call CssResource.ensureInjected(). From the documentation; At runtime, call CssResource.ensureInjected() to inject the contents of the stylesheet. - This method is safe to call multiple times, as subsequent...
Add another selector that is more specific: #login-light.bg-green { background-color: green; } ...