图片展示如下

代码如下

1.Css

  1. <style>
  2. .main{
  3. text-align: center;
  4. margin: 0px auto;
  5. width: 300px;
  6. }
  7. .container {
  8. width: 300px;
  9. height: 300px;
  10. line-height: 300px;
  11. }
  12. </style>

2.js

  1. <div class="main">
  2. <div class="container"> hello</div>
  3. <button id="bg">修改背景颜色</button>
  4. <button id="size">修改字体大小</button>
  5. </div>
  6. <script>
  7. var con=document.querySelector('.main');
  8. var bgColor=localStorage.getItem('bgColor') || '#0ff';
  9. var FSize=localStorage.getItem('FSize') || '35px';
  10. con.style.background = bgColor;
  11. con.style.fontSize = FSize;
  12. document.querySelector('#bg').onclick = function(){
  13. bgColor = prompt('请输入颜色');
  14. localStorage.setItem('bgColor',bgColor);
  15. con.style.background = bgColor;
  16. }
  17. document.querySelector('#size').onclick=function(){
  18. FSize=parseInt(prompt('请输入字体大小'))+'px';
  19. localStorage.setItem('FSize',FSize);
  20. con.style.fontSize=fontSize;
  21. }
  22. </script>

更多相关文章

  1. android EditText设置不可写
  2. Android(安卓)Activity的启动
  3. APP开发实战94-Vector静态图的使用
  4. Android(安卓)开发中的倒计时
  5. android style
  6. Gradle多渠道打包
  7. [APP] Android(安卓)开发笔记 006-使用短信验证SDK进行短信验证
  8. Android(安卓)5.x特性概览二
  9. android listview custom style 自定义样式

随机推荐

  1. Android 编译系统理解:envsetup.sh学习
  2. android软键盘把页面挤上去的解决方法
  3. Android中xml解析
  4. 【Android 应用开发】GitHub 优秀的 Andr
  5. [android]android命令行截图
  6. Android应用程序的权限列表
  7. Android在应用中固定屏幕方向
  8. android ExpandableListView简单例子
  9. OpenGL ES for Android 绘制线
  10. 修改ZXing for Android为竖屏模式