我正在为iphone网站创建一个胶粘物提醒应用程序.目标是让用户根据自己的需要创建尽可能多的“胶粘物” – 所有数据都将使用localstorage保存.
我在这里有一个工作原型的胶粘物:
$( function() {
$('#sticky-edit').bind( 'taphold', function( e ) {
alert( 'You tapped and held!' );
var thetext = localStorage.getItem("sticky");
$(".sticky-text").html('<input id="sticky-input" type="text" value="'+thetext+'" />');
} );
$('#sticky-submit').bind( 'taphold', function( e ) {
var data = $("#sticky-input").val();
alert('Notes Saved!');
localStorage.setItem("sticky", data);
$(".sticky-text").text(localStorage.getItem("sticky")).show();
} );
} );
$(".sticky-text").text(localStorage.getItem("sticky")).show();
#stickies li {
position: relative;
width: 200px;
min-height: 100px;
margin: 25px auto;
padding: 15px;
background: #f1f3a2;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(247,247,210,1)), to(rgba(240,242,155,1)));
background: -moz-linear-gradient(top, rgba(247,247,210,1), rgba(240,242,155,1));
-webkit-box-shadow: 0 2px 12px rgba(0,0,0,.5);
-moz-box-shadow: 0 2px 12px (rgba(0,0,0.5));
box-shadow: 0 1px 2px #000;
-webkit-transform: rotate(-.5deg);
-moz-transform: rotate(-.5deg);
-o-transform: rotate(-.5deg);
text-align: center;
color: #000;
text-shadow: white 1px 1px 0px;
list-style: none;
}
#stickies li:nth-child(even) {
-webkit-transform: rotate(.5deg);
-moz-transform: rotate(.5deg);
-o-transform: rotate(.5deg);
}
#stickies li::before {
content: ' ';
display: block;
position: absolute;
left: 65px;
top: -15px;
width: 75px;
height: 25px;
z-index: 2;
background-color: rgba(243,245,228,0.5);
border: 2px solid rgba(255,255,255,0.5);
-webkit-box-shadow: 0 0 5px #888;
-moz-box-shadow: 0 0 5px #888;
box-shadow: 2px 2px 2px #000;
-webkit-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
}
#stickies li:nth-child(even)::before {
-webkit-transform: rotate(3deg);
-moz-transform: rotate(3deg);
-o-transform: rotate(3deg);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul id="stickies">
<li>
<p class="sticky-text">Hello</p>
<a id="sticky-edit">Edit</a>
<a id="sticky-submit">Submit</a>
</li>
</ul>
现在,我需要做的就是弄清楚如何让用户创建尽可能多的胶粘物,每个胶粘物都有自己的本地存储区域.这可能与jquery或使用PHP来实现这一点更容易吗?
解决方法:
我曾在Flash中做过一次.你当地的存储区是什么意思?您可以让用户尽可能多地使用这个:http://jsfiddle.net/NegYd/14/使用javascript / jquery.关键是:
function appendSticky(){
var e= document.getElementById("submittext").value;
$("#stickies").append("<li>"+e+"</li>");
$.post("store.php", { text: e} );//you'll have to submit user information
}
和HTML:
<input id="submittext" type='text'/>
<input type='submit' value='add note' onClick="javascript:appendSticky();"/>
在store.php中,然后将stickies存储到MySQL数据库中. $的SQL = “INSERT ..”
我建议用浮动组织胶粘物:左;使用随机margin-leftvalue而不是最终post-it感觉的列表.或者甚至更好,使其后拖拉.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。