Home Web Front-end HTML Tutorial 手机端分类页面的效果图实现_html/css_WEB-ITnose

手机端分类页面的效果图实现_html/css_WEB-ITnose

Jun 24, 2016 am 11:23 AM

啥都不说先上效果图吧。

看到效果图,我首先把页面分割为以下模块。

其中有几个要注意的点:

1、点击板块1中的"城市1"、"城市2"等会切换版块2中不同的div模块;

2、板块2中有不同的div模块,它们的布局都如板块2所示,但只显示一个div模块,其它模块隐藏;

3、点击某个div模块中leftBar的某一项,会在rightBar中显示相对应的rightBar模块,其它rightBar模块隐藏。

4、header要固定在页首。

5、页面布局用百分比来设定,调节width,以适应不同屏幕。

6、为适应不同手机屏幕,要在head标签内加上下面的一句代码:

     

 

现在解释下各部分实现的难点。

一、header部分

1、要固定页首,所以设置header为: position:fixed; top:0;

2、设置好header的高度,这到后面会有用的。

3、板块1中的"城市1"、"城市2",我直接用ul、li布局,

     设置li为 display: inline-block;

     为了实现分割线(如下图),我设置了li的padding和border-right,最后一个li设置 border-right:none; 即可。

4、header的背景图可用CSS3背景颜色渐变或图片解决,我偷了下懒,直接用图片。

 

二、leftBar部分

1、leftBar中的选项还是用ul、li来布局,至于leftBar我设的是float:left。

2、在完成leftBar过程中,我遇到两个问题:一是leftBar如何实现在rightBar中滚动内容时,leftBar保持固定在屏幕左端,且高度要延伸至屏幕底部。

   

先谈谈这个问题怎么解决吧,一开始直接设定了leftBar的高度为100%,但发现没什么用。在老大的提示下,先设置了html、body等leftBar的父元素的高度为100%,再设leftBar的高度为100%,就解决了高度问题。

 

为实现在rightBar中滚动内容时,leftBar保持固定在屏幕左端,我把leftBar设了position:fixed; 因为leftBar高度为屏幕高度的100%,所以导致leftBar过长,会无故出现竖直方向上的滚动条,为解决这个问题,我设了整个板块2为position:absolute; top:0 ;    再调节leftBar和rightBar的padding-top为header的高度即可。(板块2我也设了float:left; 所以它能包住leftBar&rightBar)

 

但是又出现了一个问题,leftBar有部分覆盖在header上,这时,我就设了header为position:relative; z-index:100; 让header悬浮在leftBar上即可。

 

问题二:怎么使leftBar上的选中选项的右边没有边?

一开始我是设了每个选项的border-right,但发现这条边是一直延伸至下方的。

在老大的提示下,我直接设了leftBar的border-right,对于选中项用margin-right:-1px;就可以把边挡住,但我用的是margin-left:1px;不知道为什么一开始margin-right起作用,后来又不起作用(希望有人能解释下,O(∩_∩)O谢谢)。

 

三、rightBar部分

rightBar部分比较简单,为了方便,我直接用table来布局,比较整齐,同样rightBar也要设padding-top为header的高度,其它应该没什么问题。

 

JS切换模块部分比较简单,我就省略不讲了。

如果有人想探讨交流或要源码,可以留言,O(∩_∩)O谢谢

如有不足,请帮我指出。

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1673
14
PHP Tutorial
1278
29
C# Tutorial
1257
24
HTML: The Structure, CSS: The Style, JavaScript: The Behavior HTML: The Structure, CSS: The Style, JavaScript: The Behavior Apr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML, CSS, and JavaScript: Web Development Trends The Future of HTML, CSS, and JavaScript: Web Development Trends Apr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The Future of HTML: Evolution and Trends in Web Design The Future of HTML: Evolution and Trends in Web Design Apr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative Overview HTML vs. CSS vs. JavaScript: A Comparative Overview Apr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML vs. CSS and JavaScript: Comparing Web Technologies HTML vs. CSS and JavaScript: Comparing Web Technologies Apr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTML: Is It a Programming Language or Something Else? HTML: Is It a Programming Language or Something Else? Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

Beyond HTML: Essential Technologies for Web Development Beyond HTML: Essential Technologies for Web Development Apr 26, 2025 am 12:04 AM

To build a website with powerful functions and good user experience, HTML alone is not enough. The following technology is also required: JavaScript gives web page dynamic and interactiveness, and real-time changes are achieved by operating DOM. CSS is responsible for the style and layout of the web page to improve aesthetics and user experience. Modern frameworks and libraries such as React, Vue.js and Angular improve development efficiency and code organization structure.

What is the difference between <strong>, <b> tags and <em>, <i> tags? What is the difference between <strong>, <b> tags and <em>, <i> tags? Apr 28, 2025 pm 05:42 PM

The article discusses the differences between HTML tags , , , and , focusing on their semantic vs. presentational uses and their impact on SEO and accessibility.

See all articles