Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Div Draggable using CSS

Tags:

html

css

I want to make my div tag with id "drag_me" to be draggable up to the length of 300px from left and 460px from top, only using CSS.

I also want to make it resizable. Again same condition as above i.e. no Javascript or jquery.

Can any one suggest the solution for this...

Thanks in advance to all

like image 502
Jeet Avatar asked Nov 23 '12 10:11

Jeet


People also ask

How do you make a draggable element in CSS?

To make an object draggable set draggable=true on that element. Just about anything can be drag-enabled: images, files, links, files, or any markup on your page.

Can a div be draggable?

Btw, you can make a div "draggable" without JS, but you cannot "drag" it.


1 Answers

This is the best you can do without JavaScript:

[draggable=true] {    cursor: move;  }    .resizable {    overflow: scroll;    resize: both;    max-width: 300px;    max-height: 460px;    border: 1px solid black;    min-width: 50px;    min-height: 50px;    background-color: skyblue;  }
<div draggable="true" class="resizable"></div>

Demo

  • draggable attribute on HTML5 Rocks
  • CSS resize property on MDN
like image 107
Web_Designer Avatar answered Nov 15 '22 21:11

Web_Designer