web299.com
全部
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
首页
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
当前位置:
首页
>
网站模板
>
后台模板
HTML5全屏两列布局网页模板
分类:
后台模板
日期:
2024-05-14
点击(2)
评论(0)
演 示
免费下载
简介
###### 简要教程 这是一款非常有创意和实用的HTML5全屏两列布局网页模板。在大屏幕设备中,该模板以两列布局的方式出现,用户可以通过点击导航按钮来切换页面,新的内容会覆盖旧的内容。在小屏幕设备上,会以画廊的显示显示所有的项目,点击相应的项目会全屏滑出相应的内容面板。 ###### 制作方法 HTML结构 该两列布局网页模板的HTML结构分为两个主要的部分:第一个是所有项目的图片-.cd-images-list,它们都被设置为背景图片。第二个是项目的描述部分。这两个部分分别被包裹在不同的
中。另外还使用ul.block-navigation来制作整个项目的导航按钮。 ```html
2 Blocks Template
Project Two
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facere, illo!
Lorem ipsum dolor sit amet, consectetur.
Close
← Prev
Next →
``` ##### CSS样式 在移动手机等小屏幕设备中,.cd-content-block 元素(它包含项目的描述信息)使用固定定位,并且开始时被移动到屏幕之外,因此只有项目的图片列表可以被看见。当用户点击或触摸了某个项目图片,.cd-content-block元素被移动回屏幕中(使用.is-visible class),这时对应的项目描述信息会被添加.is-selected class。没有被添加这个class的项目的opacity和visibility属性会分布设置为0和hidden。 ```html .cd-content-block { /* move the block outside the viewport (to the right) - mobile only */ position: fixed; z-index: 1; top: 0; left: 0; transform: translateX(100%); transition: transform 0.3s; } .cd-content-block.is-visible { transform: translateX(0); } .cd-content-block > ul > li { position: absolute; height: 100%; overflow-y: scroll; opacity: 0; visibility: hidden; } .cd-content-block > ul > li.is-selected { /* this is the selected content */ position: relative; opacity: 1; visibility: visible; } ``` 在大屏幕的设备中(视口大于768像素),.cd-image-block(项目图片)和.cd-content-block(项目描述)分别设置为50%宽度,和100%高度,以及一个overflow: hidden属性。这样可以使不在这个区域中的子元素隐藏起来。 默认情况下,.cd-image-block > ul > li和.cd-content-block > ul > li元素都被移动到右侧屏幕之外(使用translateX(100%))。因为它们的父元素设置了overflow: hidden,所以它们是不可见的。 当某个项目被选择的时候,相应的项目图片和项目说明被添加.is-selected class,移动回屏幕中,这时它们变为可见状态。 ```html @media only screen and (min-width: 768px) { .cd-image-block, .cd-content-block { /* slider style - desktop version only */ width: 50%; float: left; height: 100vh; overflow: hidden; } .cd-image-block > ul, .cd-content-block > ul { position: relative; height: 100%; } .cd-image-block > ul > li, .cd-content-block > ul > li { position: absolute; top: 0; left: 0; height: 100%; width: 100%; /* by default, the items are moved to the right - relative to their parent elements */ transform: translateX(100%); transition: transform 0.5s; } .cd-image-block > ul > li.is-selected, .cd-content-block > ul > li.is-selected { /* this is the visible item */ position: absolute; transform: translateX(0); } .cd-image-block > ul > li.move-left, .cd-content-block > ul > li.move-left { /* this is the item hidden on the left */ transform: translateX(-100%); } } ``` ##### JAVASCRIPT 该两列布局模板使用jQuery来实现项目的导航功能。并在移动手机版本中监听.cd-images-list > li > a元素的点击事件来打开相应的项目面板。 updateBlock()函数用于更新可见的项目,它在大屏幕和小屏幕中都起作用。 ```html function updateBlock(n, device) { //n is the index of the selected project var imageItem = imagesList.eq(n), //imageList contains the .cd-images-list > li elements contentItem = contentList.eq(n); //contentList contains the .cd-content-block > ul > li elements //this function assigns the is-selected class to the 2 selected list items, removing it from their siblings classUpdate($([imageItem, contentItem])); if( device == 'mobile') { //on mobile version contentItem.scrollTop(0); //add a cover layer to the images $('.cd-image-block').addClass('content-block-is-visible'); //move the slide-in panel back into the viewport contentWrapper.addClass('is-visible'); } else { //hide scrolling bar while changing project content contentList.addClass('overflow-hidden'); contentItem.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){ //wait for the end of the animation contentItem.siblings().scrollTop(0); contentList.removeClass('overflow-hidden'); }); } //this function updates the visibility of the .block-navigation buttons according to visible project updateBlockNavigation(n); } ```
相关推荐
设计团队博客css网站模板
无人机数码商店网站模板
移动版猎豹安全浏览器官网html5动画引导页
微信小程序的手势密码
白色简约布局html5模板
响应式商品展示和商品信息比较网格布局界面
广告
广告