Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Dynamic UI behavior with AngularJS attributes
type="row" start="open"
type="column" start="close"
type="accordion" start="open"
css
*, *::before, *::after { box-sizing: border-box; } body { font-family: 'Open Sans', sans-serif; margin: 0; padding: 0; } .flex { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; align-items: stretch; } .flex-center { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: stretch; } .flex-column { display: flex; flex-direction: column; flex-wrap: wrap; justify-content: center; align-items: stretch; } .flex-column-center { display: flex; flex-direction: column; flex-wrap: wrap; justify-content: flex-start; align-items: center; } .flex-column-center-center { display: flex; flex-direction: column; flex-wrap: wrap; justify-content: center; align-items: center; } h2, h3 { color: white; text-align: center; padding-top: 1em; margin: 0; } .page-container { position: relative; background-image: url(http://subtlepatterns2015.subtlepatterns.netdna-cdn.com/patterns/swirl_pattern.png); z-index: 1; border: 0.5em solid white; } .page-container .swirl-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #5C18BC; z-index: -1; opacity: 0.7; } .page-container .half-width { width: 49%; } .divider-bottom { border-bottom: 0.5em solid white; opacity: 1; } .divider-right { border-right: 0.5em solid white; } .content-container { font-size: 0.8em; } .content-container .content { margin: 1em; } .content-container .content .item { background-color: white; box-shadow: 0 0.2em 0.5em 0 rgba(0, 0, 0, 0.26); margin: 1em; width: 27em; } .content-container .content .item.accordion { margin-top: 0; margin-bottom: 0; } .content-container .content .item:not(.open) { height: 7em; } .content-container .content .item.open header:hover i:last-child { transform: rotate(-90deg); } .content-container .content .item header { position: relative; padding: 2.5em 1em 2.5em 1em; text-align: center; border-bottom: 0.1em solid rgba(0, 0, 0, 0.16); color: grey; transition: background-color 0.2s linear; cursor: pointer; } .content-container .content .item header i { font-size: 2em; position: absolute; font-weight: bold; } .content-container .content .item header i:first-child { color: #5C18BC; left: 1em; } .content-container .content .item header i:last-child { color: #5C18BC; right: 1em; width: 1.1em; height: 1.1em; padding-left: 0.1em; transition: all 0.2s ease-in; } .content-container .content .item header span { cursor: default; font-size: 1.4em; line-height: 1.6em; } .content-container .content .item header:hover { box-shadow: 0 0 0.3em rgba(0, 0, 0, 0.26); background-color: #332C7C; } .content-container .content .item header:hover i:first-child { color: white; } .content-container .content .item header:hover i:last-child { background-color: white; color: #5C18BC; transform: rotate(90deg); border-radius: 50%; box-shadow: 0 0 0.2em rgba(0, 0, 0, 0.7); } .content-container .content .item header:hover span { color: white; } .content-container .content .item section { padding: 1em; background-color: white; } .content-container .content .item section .title { font-weight: bold; margin-bottom: 1em; } .content-container .content .item section .links .link { color: #5C18BC; margin-bottom: 0.5em; cursor: pointer; transition: all 0.1s ease-in; } .content-container .content .item section .links .link:hover { margin-left: 1em; font-weight: bold; }
JavaScript
var PageApp = angular.module('angularPageApp', ['ngSanitize']); PageApp.controller('linkListWidgetCtrl', function($scope) { // define defaults for the directive behavior in case none are // provided as html attributes (see directive link function below) $scope.type = 'row'; $scope.start = 'open'; // content a some ui direction taken from the Google Accounts page (https://myaccount.google.com/) $scope.items = [{ header: { text: 'Sign-in & security', css: 'fa-lock', open: true }, content: { title: 'Control your password and account-access settings', links: ['Signing in to Google', 'Device activity and notifications', 'Connected apps & sites'] } }, { header: { text: 'Personal info and privacy', css: 'fa-user', open: true }, content: { title: 'Manage your visibility settings and the data we use to personalize your experience.', links: ['Your personal info', 'Activity control', 'Ads settings', 'Account overview', 'Control your content'] } }, { header: { text: 'Account preferences', css: 'fa-cog', open: true }, content: { title: 'Set language, accessibility, and other settings that help you use Google.', links: ['Language & Input Tools', 'Accessibility', 'Your Google Drive storage', 'Delete your account or services'] } }]; // called once from directive link function if the type is set to 'accordion' $scope.initAccordion = function() { $scope.closeAll(); if ($scope.start === 'open') { $scope.items[0].header.open = true; } }; // set the header.open boolean to false for all items // angular should update the ui for us $scope.closeAll = function() { for (var i = 0; i < $scope.items.length; i++) { $scope.items[i].header.open = false; } }; // in none-accordion cases all this does is flip the open boolean for // the clicked header. if our type is accordion and we're opening a // currently closed item, we close all items before opening the clicked one $scope.headerClick = function(header) { if ($scope.type === 'accordion' && header.open === false) { $scope.closeAll(); } header.open = !header.open; }; }); PageApp.directive('linkListWidget', function($timeout) { return { restrict: 'E', template: [ '
', '
', '
', '
', '
', '
{{ item.header.text }}
', '
', '
', '
', '
{{ item.content.title }}
', '
', '
{{ link }}
', '
', '
', '
', '
', '
' ].join(''), link: function(scope, element, attrs) { // feed any attributes defined in the html into our controller's scope if (attrs.type) { scope.type = attrs.type; } if (attrs.start) { scope.start = attrs.start; } if (scope.start === 'close') { scope.closeAll(); } if (scope.type === 'accordion') { scope.initAccordion(); } } }; });
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>用AngularJS实现动态UI-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号