Foundation Getting Started
What is Foundation?
- Foundation is a free front-end framework for rapid development.
- Foundation includes HTML and CSS design templates and provides a variety of UI components on the Web, such as forms, buttons, tabs, and more. It also provides a variety of JavaScript plugins.
- Foundation is mobile-first and can create responsive web pages.
- Foundation is suitable for beginners and professionals.
- Foundation has been used by Facebook, eBay, Samsung, Amazon, Disney, etc.
|
| **What is responsive web design?
**
The idea of responsive web design is that page design and development should respond and adjust according to user behavior and device environment (system platform, screen size, screen orientation, etc.). | | --- | --- |
Where to download Foundation?
You can get Foundation in the following two ways:
1. Download the latest version from the official website:http://foundation.zurb.com/。
2. Use the CDN provided by Staticfile (recommended):
This site's static CDN is based on Aliyun services.
|
| Advantages of using CDN for Foundation:
Using CDN for Foundation improves the access speed of enterprise sites (especially sites with many images and static pages) and greatly improves the stability of such sites
**为什么使用 modernizr?**
Some Foundation 的组件使用了比较前前沿的 HTML5 和 CSS3 特性,但不是所有浏览器都支持。 Modernizr 是一个用于检测用户浏览器HTML5和CSS3特性的JavaScript库 - 让组件能在所有浏览器上正常运行。 |
| --- | --- |
Creating Pages with Foundation
1. Add HTML5 doctype
Foundation uses HTML elements and CSS properties, so you need to add the HTML5 doctype declaration.
At the same time, we can set the document's language attribute lang and character encoding:
<
!DOCTYPE
html
<
html
lang=
"zh-cn"
<
head
<
meta
charset=
"utf-8"
<
/head
<
/html2. Foundation 5 Mobile First
Foundation 5 is responsive design for mobile devices. The core of the framework is mobile first.
To ensure the page can be freely scaled, you can add in the element the following tag:
<
meta
name=
"viewport"
content="width=device-width, initial-scale=1"
- width: controls the size of the viewport. You can specify a value, such as 600, or a special value such as device-width, which is the width of the device (in CSS pixels when scaled to 100%).
- initial-scale: the initial scale ratio, that is, the scale when the page is first loaded.
3. Initialize Components
Some Foundation components are developed based on jQuery, such as modals, dropdowns, etc. You can use the following script to initialize the components:
<
script
$(document).ready(function() {
$(document).foundation();
})
<
/script
Basic Foundation Page
How to create a basic Foundation page:
Foundation Example
<div class="row">
<div class=">medium-12 columns
"
<div class="panel">
<h1>Foundation Page
h1
<
p
Resize the window to see the effect!
p
<button type="button" class=">button small
"
I am a button!
button
div
div
div
<div class="row">
<div class=">medium-4 columns
"
<
h3
Runoob Tutorial
h3
<
p
What you learn is not just technology, but also dreams!!!
p
div
<div class=">medium-4 columns
"
<
h3
Runoob Tutorial
h3
<
p
What you learn is not just technology, but also dreams!!!
p
div
<div class=">medium-4 columns
"
<
h3
Runoob Tutorial
h3
<
p
What you learn is not just technology, but also dreams!!!
p
div
div
Try it »