install : package 설치할때 사용하는 명령어, 가장 많이 쓰이고 대표적이다.
npm install --save react-native-device-info
link
react-native link react-native-device-info
npm install --save react-native-device-info
react-native link react-native-device-info
Lodash is a JavaScript library which provides utility functions for common programming tasks using the functional programming paradigm. Wikipedia
Initial release date: April 23, 2012 / License: MIT
Lodash는 함수형 프로그래밍 패러다임을 사용하여 일반적인 프로그래밍 작업을 위한 유틸리티 기능을 제공하는 JavaScript 라이브러리입니다.
모듈성, 성능 및 추가 기능을 제공하는 최신 자바스크립트 유틸리티 라이브러리입니다.
Lodash is released under the MIT license & supports modern environments.Review the build differences & pick one that’s right for you.
Lodash는 MIT 라이선스에 따라 출시되었으며 최신 환경을 지원합니다. 빌드 차이점을 검토하고 적합한 것을 선택하십시오.
브라우저에서 바로 사용하기 | In a browser:
<script src="lodash.js"></script>
NPM 사용하기 | Using npm:
$ npm i -g npm
$ npm i --save lodash
Node에서 사용하기 | In Node.js:
// Load the full build.
var _ = require('lodash');
// Load the core build.
var _ = require('lodash/core');
// Load the FP build for immutable auto-curried iteratee-first data-last methods.
var fp = require('lodash/fp');
// Load method categories.
var array = require('lodash/array');
var object = require('lodash/fp/object');
// Cherry-pick methods for smaller browserify/rollup/webpack bundles.
var at = require('lodash/at');
var curryN = require('lodash/fp/curryN');
노트 | Note:
Node.js < 6 REPL 에서 Lodash 사용을 위해 n_를 설치합니다.
Lodash makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc.Lodash’s modular methods are great for:
Lodash는 배열, 숫자, 객체, 문자열 등으로 작업하는 번거로움을 없애 JavaScript를 더 쉽게 만듭니다.Lodash의 모듈식 메서드는 다음과 같은 경우에 적합합니다.
Lodash is available in a variety of builds & module formats.
Lodash는 다양한 빌드 및 모듈 형식으로 제공됩니다.
futil-js는 lodash를 보완하도록 설계된 기능 유틸리티 세트입니다.
Chrome 74-75, Firefox 66-67, IE 11, Edge 18, Safari 11-12, & Node.js 8-12에서 테스트 되었습니다.
[JS] Array.Sort() 사용하기 (0) | 2019.09.04 |
---|
#제공 데이터 중 최신컨텐츠 우선으로 정렬하고, 정렬순번으로 오름차순으로 정렬하기
d.list.sort((a,b) => a.newYn > b.newYn ? -1 : (a.sortNum > b.sortNum ? 1:-1));
- 사용방법
[].sort(conditionFunction);
//1,2,3,8,9 오름차순
var arr = [2, 9, 8, 3, 1]
print(arr.sort());
//9,8,3,2,1 내림차순
//#1
var arr = [2, 9, 8, 3, 1];
console.log(arr.sort(function(a,b){
return b-a;
}));
//#2
var arr = [2, 9, 8, 3, 1];
console.log(arr.sort(orderByDesc));
function orderByDesc(a,b){
return b-a;
}
//#3
var arr = [2, 9, 8, 3, 1];
console.log(arr.sort((a,b)=> b-a));
[JS] Lodash? (6) | 2024.09.12 |
---|
convert this string into array of objects
using the JSON native parser, as it is not only faster than the eval(), it's also more secure.
Native JSON parser is already available in:
Firefox 3.5+ IE 8+ Opera 10.5+ Safari Safari 4.0.3+ Chrome (don't know which version)
var myJSONString = '{ "a": 1, "b": 2 }';
myObject = JSON.parse(myJSONString);
Get Start Less (0) | 2014.09.02 |
---|---|
.prependTo() (0) | 2014.08.22 |
make an Interactive Website 5 coding (0) | 2014.08.22 |
margin by codecademy (0) | 2014.08.21 |
ASP.NET MVC4 WEB API (1) | 2013.10.22 |
http://lesscss.org/
Less is a CSS pre-processor, meaning that it extends the CSS language, adding features that allow variables, mixins, functions and many other techniques that allow you to make CSS that is more maintainable, themable and extendable.
Less runs inside Node, in the browser and inside Rhino. There are also many 3rd party tools that allow you to compile your files and watch for changes.
For example:
@base: #f938ab;
.box-shadow(@style, @c) when (iscolor(@c)) {
-webkit-box-shadow: @style @c;
box-shadow: @style @c;
}
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
.box-shadow(@style, rgba(0, 0, 0, @alpha));
}
.box {
color: saturate(@base, 5%);
border-color: lighten(@base, 30%);
div { .box-shadow(0 0 5px, 30%) }
}
compiles to
.box {
color: #fe33ac;
border-color: #fdcdea;
}
.box div {
-webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
Less can be used on the command line via npm, downloaded as a script file for the browser or used in a wide variety of third party tools. See the Usage section for more detailed information.
The easiest way to install Less on the server, is via npm, the node.js package manager, as so:
$ npm install -g less
Once installed, you can invoke the compiler from the command-line, as such:
$ lessc styles.less
This will output the compiled CSS to stdout
, you may then redirect it to a file of your choice:
$ lessc styles.less > styles.css
To output minified CSS, simply pass the -x
option. If you would like more involved minification, the Clean CSS is also available with the --clean-css
option.
To see all the command line options run lessc without parameters.
You can invoke the compiler from node, as such:
var less = require('less');
less.render('.class { width: (1 + 1) }', function (e, css) {
console.log(css);
});
which will output
.class {
width: 2;
}
you may also manually invoke the parser and compiler:
var parser = new(less.Parser);
parser.parse('.class { width: (1 + 1) }', function (err, tree) {
if (err) {
return console.error(err)
}
console.log(tree.toCSS());
});
You may pass some options to the compiler:
var parser = new(less.Parser)({
paths: ['.', './lib'], // Specify search paths for @import directives
filename: 'style.less' // Specify a filename, for better error messages
});
parser.parse('.class { width: (1 + 1) }', function (e, tree) {
tree.toCSS({
// Minify CSS output
compress: true
});
});
See the Usage section for details of other tools.
Each less.js release contains also rhino-compatible version.
Command line rhino version requires two files:
Command to run the compiler:
java -jar js.jar -f less-rhino-<version>.js lessc-rhino-<version>.js styles.less styles.css
This will compile styles.less file and save the result to styles.css file. The output file parameter is optional. If it is missing, less will output the result to stdout
.
Using less.js in the browser is great for development, but it's not recommended for production
Client-side is the easiest way to get started and good for developing with Less, but in production, when performance and reliability is important, we recommend pre-compiling using node.js or one of the many third party tools available.
To start off, link your .less
stylesheets with the rel
attribute set to "stylesheet/less
":
<link rel="stylesheet/less" type="text/css" href="styles.less" />
Next, download less.js and include it in a <script></script>
tag in the <head>
element of your page:
<script src="less.js" type="text/javascript"></script>
.less
stylesheet each of them is compiled independently. So any variables, mixins or namespaces you define in a stylesheet are not accessible in any other.Options are defined by setting them on a global less
object before the <script src="less.js"></script>
:
<!-- set options before less.js script -->
<script>
less = {
env: "development",
async: false,
fileAsync: false,
poll: 1000,
functions: {},
dumpLineNumbers: "comments",
relativeUrls: false,
rootpath: ":/a.com/"
};
</script>
<script src="less.js"></script>
Learn more about Browser Options
Less.js is released under the Apache 2 License (though there are plans to dual license it). Copyright 2009-2014, Alexis Sellier and the Less Core Team (see about). Boiled down to smaller chunks, it can be described with the following conditions.
The full Less.js license is located in the project repository for more information.
[JS] JSON.parse : Convert this string into array of objects (0) | 2016.08.20 |
---|---|
.prependTo() (0) | 2014.08.22 |
make an Interactive Website 5 coding (0) | 2014.08.22 |
margin by codecademy (0) | 2014.08.21 |
ASP.NET MVC4 WEB API (1) | 2013.10.22 |
Bootstrap uses Grunt for its build system, with convenient methods for working with the framework. It's how we compile our code, run tests, and more.
bootstrap은 프레임워크 동작의 편리를 위해 Grunt 의 빌드시스템을 사용한다. 아래는, 우리가 어떻게 코드를 컴파일하고, 테스트와 기타 외작업을 어떻게 하는지 설명한다.
To install Grunt, you must first download and install node.js (which includes npm). npm stands for node packaged modules and is a way to manage development dependencies through node.js.
Then, from the command line:
grunt-cli
globally with npm install -g grunt-cli
./bootstrap/
directory, then run npm install
. npm will look at the package.json
file and automatically install the necessary local dependencies listed there.When completed, you'll be able to run the various Grunt commands provided from the command line.
grunt-cli
을 grunt dist
(Just compile CSS and JavaScript)Regenerates the /dist/
directory with compiled and minified CSS and JavaScript files. As a Bootstrap user, this is normally the command you want.
grunt watch
(Watch)Watches the Less source files and automatically recompiles them to CSS whenever you save a change.
grunt test
(Run tests)Runs JSHint and runs the QUnit tests headlessly in PhantomJS.
grunt
(Build absolutely everything and run tests)Compiles and minifies CSS and JavaScript, builds the documentation website, runs the HTML5 validator against the docs, regenerates the Customizer assets, and more. Usually only necessary if you're hacking on Bootstrap itself.
Should you encounter problems with installing dependencies or running Grunt commands, first delete the /node_modules/
directory generated by npm. Then, rerun npm install
.
GRUNT : The JavaScript Task Runner (0) | 2014.09.02 |
---|
http://gruntjs.com/
Getting started
Grunt and Grunt plugins are installed and managed via npm, the Node.js package manager. Grunt 0.4.x requires stable Node.js versions >= 0.8.0
. Odd version numbers of Node.js are considered unstable development versions.
Before setting up Grunt ensure that your npm is up-to-date by running npm update -g npm
(this might requiresudo
on certain systems).
Using Grunt 0.3? Please see Grunt 0.3 Notes
In order to get started, you'll want to install Grunt's command line interface (CLI) globally. You may need to use sudo (for OSX, *nix, BSD etc) or run your command shell as Administrator (for Windows) to do this.
npm install -g grunt-cli
This will put the grunt
command in your system path, allowing it to be run from any directory.
Note that installing grunt-cli
does not install the Grunt task runner! The job of the Grunt CLI is simple: run the version of Grunt which has been installed next to a Gruntfile
. This allows multiple versions of Grunt to be installed on the same machine simultaneously.
1. node.js 설치
2. cmd에서 명령어 입력
Each time grunt
is run, it looks for a locally installed Grunt using node's require()
system. Because of this, you can run grunt
from any subfolder in your project.
If a locally installed Grunt is found, the CLI loads the local installation of the Grunt library, applies the configuration from your Gruntfile
, and executes any tasks you've requested for it to run. To really understand what is happening, read the code.
Working with an existing Grunt project
Assuming that the Grunt CLI has been installed and that the project has already been configured with apackage.json
and a Gruntfile
, it's very easy to start working with Grunt:
npm install
.grunt
.That's really all there is to it. Installed Grunt tasks can be listed by running grunt --help
but it's usually a good idea to start with the project's documentation.
A typical setup will involve adding two files to your project: package.json
and the Gruntfile
.
package.json: This file is used by npm to store metadata for projects published as npm modules. You will list grunt and the Grunt plugins your project needs as devDependencies in this file.
Gruntfile: This file is named Gruntfile.js
or Gruntfile.coffee
and is used to configure or define tasks and load Grunt plugins. When this documentation mentions a Gruntfile
it is talking about a file, which is either a Gruntfile.js
or a Gruntfile.coffee
.
The package.json
file belongs in the root directory of your project, next to the Gruntfile
, and should be committed with your project source. Running npm install
in the same folder as a package.json
file will install the correct version of each dependency listed therein.
There are a few ways to create a package.json
file for your project:
package.json
file.package.json
file.{
"name": "my-project-name",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.4.1",
"grunt-contrib-uglify": "~0.5.0"
}
}
The easiest way to add Grunt and gruntplugins to an existing package.json
is with the commandnpm install <module> --save-dev
. Not only will this install <module>
locally, but it will automatically be added to the devDependencies section, using a tilde version range.
For example, this will install the latest version of Grunt in your project folder, adding it to your devDependencies:
npm install grunt --save-dev
The same can be done for gruntplugins and other node modules. Be sure to commit the updatedpackage.json
file with your project when you're done!
프로젝트 파일의 root 지점으로 이동한 뒤, Grunt를 설치한다.
그럼, node_modules 이라는 폴더가 생성되고, 그 안에 생성된 Grunt라는 폴더에는 다음과 같은 파일들이 함께 생성된다.
The Gruntfile.js
or Gruntfile.coffee
file is a valid JavaScript or CoffeeScript file that belongs in the root directory of your project, next to the package.json
file, and should be committed with your project source.
A Gruntfile
is comprised of the following parts:
In the following Gruntfile
, project metadata is imported into the Grunt config from the project'spackage.json
file and the grunt-contrib-uglify plugin's uglify
task is configured to minify a source file and generate a banner comment dynamically using that metadata. When grunt
is run on the command line, theuglify
task will be run by default.
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('default', ['uglify']);
};
Now that you've seen the whole Gruntfile
, let's look at its component parts.
Every Gruntfile
(and gruntplugin) uses this basic format, and all of your Grunt code must be specified inside this function:
module.exports = function(grunt) {
// Do grunt-related things in here
};
Most Grunt tasks rely on configuration data defined in an object passed to the grunt.initConfig method.
In this example, grunt.file.readJSON('package.json')
imports the JSON metadata stored in package.json
into the grunt config. Because <% %>
template strings may reference any config properties, configuration data like filepaths and file lists may be specified this way to reduce repetition.
You may store any arbitrary data inside of the configuration object, and as long as it doesn't conflict with properties your tasks require, it will be otherwise ignored. Also, because this is JavaScript, you're not limited to JSON; you may use any valid JS here. You can even programmatically generate the configuration if necessary.
Like most tasks, the grunt-contrib-uglify plugin's uglify
task expects its configuration to be specified in a property of the same name. Here, the banner
option is specified, along with a single uglify target namedbuild
that minifies a single source file to a single destination file.
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
}
});
Many commonly used tasks like concatenation, minification and linting are available as grunt plugins. As long as a plugin is specified in package.json
as a dependency, and has been installed via npm install
, it may be enabled inside your Gruntfile
with a simple command:
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
Note: the grunt --help
command will list all available tasks.
You can configure Grunt to run one or more tasks by default by defining a default
task. In the following example, running grunt
at the command line without specifying a task will run the uglify
task. This is functionally the same as explicitly running grunt uglify
or even grunt default
. Any number of tasks (with or without arguments) may be specified in the array.
// Default task(s).
grunt.registerTask('default', ['uglify']);
If your project requires tasks not provided by a Grunt plugin, you may define custom tasks right inside theGruntfile
. For example, this Gruntfile
defines a completely custom default
task that doesn't even utilize task configuration:
module.exports = function(grunt) {
// A very basic default task.
grunt.registerTask('default', 'Log some stuff.', function() {
grunt.log.write('Logging some stuff...').ok();
});
};
Custom project-specific tasks don't need to be defined in the Gruntfile
; they may be defined in external.js
files and loaded via the grunt.loadTasks method.
Gruntfile
, along with an explanation of templates, globbing patterns and importing external data.http://gruntjs.com/getting-started
Compiling CSS and JavaScript (0) | 2014.09.02 |
---|
Create a new li element : $('<li>');
Select the h2 element nested insind the <div class="article"> ... </div> element. : $('.article h2');
[JS] JSON.parse : Convert this string into array of objects (0) | 2016.08.20 |
---|---|
Get Start Less (0) | 2014.09.02 |
make an Interactive Website 5 coding (0) | 2014.08.22 |
margin by codecademy (0) | 2014.08.21 |
ASP.NET MVC4 WEB API (1) | 2013.10.22 |
Let's use jQuery to build a news reader.
n
keyboard shortcut to go to the next article.o
keyboard shortcut to open the article description.n
keyboard shortcut to go to the next article.o
keyboard shortcut to open the article description.Program skeleton
The index.html file has two scriptelements right before the closing </body>
tag:
var main = function() {
};
$(document).ready(main);
Get Start Less (0) | 2014.09.02 |
---|---|
.prependTo() (0) | 2014.08.22 |
margin by codecademy (0) | 2014.08.21 |
ASP.NET MVC4 WEB API (1) | 2013.10.22 |
Javascript / text / cs 연결할 때 (59) | 2013.08.30 |
User interactions with a web page are called events.
For example, when you click the Like button to the right, the browser announces that a click event has occurred.
When a user clicks the .like-button
element, the event handler toggles the "active"
class. This alternates the button between the normal gray view and the selected blue view.
In the page to the right, click the three share buttons at the top of the page.
One common user event is the click event. A click event occurs when a user clicks on an HTML element.
The .click()
method attaches an event handler to an HTML element so that it can respond to a click event.
$('.social li')
selects each share button at the top of the web page.
The .click()
method attaches an event handler to each button.
The event handler adds the CSS class .active
, which changes the button's background-color to red. We use $(this)
to refer to the HTML element that was clicked on. We can now operate on this element using .toggleClass()
.
Putting it all together, when you click on a share button at the top of the page, a click event is triggered by the browser.
When the click event occurs, the .click()
method runs the event handler. In this code, the event handler changes the button color to red.
In the page to the right, click inside the page, and then press any letter or number key.
Another common user event is the keypress event. A keypress event occurs when a user types a key on the keyboard.
The .keypress()
method attaches an event handler to an HTML element so that it can respond to a keypress event.
$(document)
selects the whole web page.The .keypress()
method attaches an event handler to document
When any keyboard key is pressed, the event handler toggles the dropdown menu.
Putting it all together, when you press any keyboard key, a keypress event is triggered by the browser.
When the keypress event occurs, the .keypress()
method runs the event handler.
Here, the event handler toggles the dropdown menu. Putting it all together, when you press any keyboard key, a keypress event is triggered by the browser.
When the keypress event occurs, the .keypress()
method runs the event handler.
Here, the event handler toggles the dropdown menu.
In the page to the right, click inside the page, and then press the m key.
Triggering a keypress event handler when any key is typed isn't particularly useful. For more control, we can use the event
object.
The event
object contains more information about an event, such as which mouse button was clicked or which key was pressed.
$(document)
selects the whole web page, and the.keypress()
method attaches an event handler todocument
.The event handler takes event
as a parameter. event.which
contains which key was pressed. Keyboard keys are identified by key codes. The m key is identified by the key code 109.
make an Interactive Website 3 JavaScript (0) | 2014.08.22 |
---|---|
make an Interactive Website 2 Jquery coding (0) | 2014.08.22 |
make an Interactive Website 1 (0) | 2014.08.21 |
make website 3 coding (0) | 2014.08.21 |
make web site 2 bootstrap (0) | 2014.08.21 |
In order to make interactive web pages with jQuery, it's useful to know a few things about JavaScript.
JavaScript is a programming language that jQuery is written in, and knowing JavaScript will be helpful for understanding and writing your code.
The next cards will cover a few fundamental JavaScript concepts.
Variables store data so that they can be used later on in the program. The keyword var
creates a new variable namedcounter
. The value 140 is stored in counter
. The statement ends with a semicolon to tell the computer that the statement has ended.
Comparisons
It's possible to compare variables using comparisons.
>
- Greater than
<
- Less than
>=
Greater than or equal to
<=
Less than or equal to
===
Equal to score1 === score2;
!==
Not equal to
make an Interactive Website 4 Event (0) | 2014.08.22 |
---|---|
make an Interactive Website 2 Jquery coding (0) | 2014.08.22 |
make an Interactive Website 1 (0) | 2014.08.21 |
make website 3 coding (0) | 2014.08.21 |
make web site 2 bootstrap (0) | 2014.08.21 |
We are going to use jQuery to create a menu that slides out from the left side.
The index.html file has two scriptelements right before the closing </body>
tag:
Let's start by setting up the basic skeleton for JavaScript programs.
var
and create a function called main
.main
function once the web page has fully loaded./*Inside the app.js file, use the keyword var and create a function called main.*/ var main = function(){ }; /*Use jQuery to run the main function once the web page has fully loaded.*/ $(document).ready(main);
What does this skeleton do?
main
function is where we'll write our program.$(document).ready
runs the main
function as soon as the HTML document has loaded in the browser.Let's start filling out the main
function. Here, we'll select an HTML element in order to operate on it. jQuery lets us select HTML elements using CSS selectors.
main
function.main
function, use jQuery to select the class 'icon-menu'
. $('.icon-menu');$( )
to tell the computer we're using jQuery.'icon-menu'
, we type in '.icon-menu'
.We have just used jQuery to select the'icon-menu'
class using $('.icon-menu')
Now we want to respond to user action.
Specifically we want to respond to a user clicking on this '.icon-menu'
HTML element.
After $('.icon-menu')
, add the .click()
method.
We now have code that says something will happen when the user clicks on theicon-menu
HTML element. But what will happen?!
Clicking on the menu icon should open the menu.
.click()
method.'menu'
class and animate it.Right now, the menu is 285px past the left edge of the screen. That's why it is not visible! Inside the animate method:
a move it 0px to the left
b. make this happen over 200 milliseconds.
We now want to push the rest of the page to the left 285px. Use jQuery to select the body HTML element, animate it, and move it left 285px over 200 milliseconds.
Once the menu is open, we need a way to close it. Let's adapt the three steps we used to open the menu in order to close the menu.
'.icon-close'
element..click()
method.'.icon-close'
element is clicked, use .animate()
to change the left
offset of the menu to -285px, and the left
offset of the body to 0px. Both are done over 200 milliseconds.make an Interactive Website 4 Event (0) | 2014.08.22 |
---|---|
make an Interactive Website 3 JavaScript (0) | 2014.08.22 |
make an Interactive Website 1 (0) | 2014.08.21 |
make website 3 coding (0) | 2014.08.21 |
make web site 2 bootstrap (0) | 2014.08.21 |
Web pages made with HTML and CSS display static content. They don't respond to user actions like clicking a mouse or typing a key.
JavaScript and jQuery are used to make web pages interactive.
JavaScript is a programming language used to create web pages that change in response to user actions.
jQuery is a collection of prewritten JavaScript code that lets us easily create interactive effects on our site.
Click on More and the navigation arrows in the web page to the right.
Click on Flipboard at the top of the web page to the right. The web page has a dropdown menu which shows and hides when you click Flipboard.
This interaction is made with JavaScript and jQuery.
Here's what the web page's HTML looks like.
To include CSS files in HTML we used the linkelement.
Similarly, to include JavaScript files in HTML, we use the script element.
To include CSS files in HTML, we use the linkelement. The link element tells the browser where to find a CSS file.
Similarly, to include JavaScript files in HTML, we use the script element.
The script element tells the browser where to find a JavaScript file. It has an attribute inside the opening <script>
tag named src
, which has the address of the JavaScript file.
The first script loads in jQuery.
The second script loads in app.js. This is where the code for the dropdown menu program lives.
$(".dropdown-menu").show();
to $(".dropdown-menu").toggle();
to toggle the dropdown menu. Then click on Flipboard once to make the menu appear, and again to make it disappear.The $(document).ready()
waits for the HTML document to load completely before running the main()
function.
This is important because JavaScript should only run after the web page has loaded completely in the browser - otherwise there wouldn't be any HTML elements to add interactivity to.
make an Interactive Website 3 JavaScript (0) | 2014.08.22 |
---|---|
make an Interactive Website 2 Jquery coding (0) | 2014.08.22 |
make website 3 coding (0) | 2014.08.21 |
make web site 2 bootstrap (0) | 2014.08.21 |
make web site 1 by codecademy (0) | 2014.08.21 |
The navigation menus are made up of two ulelements. In each ul, the li elements display on new lines because they are block elements. Let's style the li elements so that they display on the same line. This can be done with thedisplay
property.
Nice! The menu items inside each ul now are now inline elements. [We'll see how to move the two uls to display on the same line in the next section.]
Next let's change the position of the text inside the large feature. Currently the text is positioned at the very top of the large feature. Let's move the text down so that its more in the middle of the large feature. This can be done with the position
property.
In index.html, the <div class="jumbotron">..</div>
groups elements that are part of the large feature section of the web page. Inside<div class="jumbotron">..</div>
is the <divclass="container">..</div>
which has the text
Bootstrap is a CSS framework used to build pages faster. Bootstrap provides a lot of useful CSS out of the box. Check out the Bootstrap file at "http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css" - it has CSS properties and values, many of which you've seen already, to style HTML.
Nicely done! What's going on here?
The order of the CSS files matter.
1. The browser first sees shift.css, and makes the Shift font available to use in the page
2. Next the browser sees bootstrap.css, and applies those styles to the page.
3. Then the browser sees main.css, and applies those custom styles to the page. The custom styles override the Bootstrap styles.
The order of the CSS files tell the browser that your styles in main.css are more important than the styles in bootstrap.css, so the final page that loads is the customized web page.
Navigation
In index.html inside <div class="nav">..</div>
, the navigation menus are made up of two ul elements. So far we've styled the lielements to display on the same line. Now let's style the ul elements to show up on the same line too.
Bootstrap provides the .pull-left
class to left-align an element, and the .pull-right
class to right-align an element. Let's use these classes to finish styling the navigation bar.
Looking good! Both menus now show up on the same line, and the navigation bar is complete.
Next, let's use Bootstrap's grid to arrange the three pieces of supporting content inside the<div class="learn-more">..</div>
section. Here's how to use Bootstrap's grid.
<div class="container">
<div class="row">
<div class="col-md-4">
...
</div>
<div class="col-md-4">
...
</div>
<div class="col-md-4">
...
</div>
</div>
</div>
<div class="container">..</div>
, there is a row defined by <div class="row">..</div>
<div class="row">..</div>
, there are three columns each defined by <div class="col-md-4">
Why is the .col-md-4
class being used? Remember that Bootstrap's grid is 12 columns. Therefore, to create three equal-sized columns, they each need to span 4 grid columns.
Excellent! Using Bootstrap's grid, you arranged the three pieces of supporting content into a three-column layout.
Let's use Bootstrap's grid again to create another section on the page. This section will contain a grid of images.
Nice work! Next let's add some images inside the columns.
Bootstrap provides the ".thumbnail" class to easily display grids of images. An img element is wrapped in a div element with the class "thumbnail".
<div class="row">
<div class="col-md-4">
<img src="http://goo.gl/0sX3jq" >
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="http://goo.gl/Av1pac" >
</div>
<div class="thumbnail">
<img src="http://goo.gl/vw43v1">
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<img src="http://goo.gl/0Kd7UO" >
</div>
</div>
</div>
Neighborhood Guides: Final touches
Excellent! Using Bootstrap's grid, we created a brand new section on the web page displaying a grid of images.
Let's finish up this section with a few custom CSS styles.
In main.css, make a new CSS rule that selects.neighborhood-guides
background-color
to #efefef
border-bottom
to 1px solid #dbdbdb
Make a second CSS rule that selects the h2element inside .neighborhood-guides
color
to #393c3d
font-size
to 24px
Make a third CSS rule that selects the pelement inside .neighborhood-guides
font-size
to 15px
margin-bottom
to 13px
Navigation
You've done a lot so far. You learned about HTML, CSS, and Bootstrap, and created the Airbnb home page from scratch.
Now it's time to make it your own. Let's start with the navigation bar and work our way down the page.
make an Interactive Website 3 JavaScript (0) | 2014.08.22 |
---|---|
make an Interactive Website 2 Jquery coding (0) | 2014.08.22 |
make an Interactive Website 1 (0) | 2014.08.21 |
make web site 2 bootstrap (0) | 2014.08.21 |
make web site 1 by codecademy (0) | 2014.08.21 |
We saw how to use CSS rules to control the style and layout of a page.
Bootstrap is a collection of prewritten CSS rules used to build web pages faster. Bootstrap provides styles out of the box for several common components on a web page, such as grid layouts, navigation, showcases, and much more.
Let's see how to get started using Bootstrap in your web page.
A grid is a useful way to create page layouts. Rather than create layouts from scratch, HTML elements can be aligned to a grid in different ways to create custom layouts.
Bootstrap comes with a grid that is made up of 12 equal-sized columns. HTML elements are arranged to span different numbers of columns in order to create custom page layouts.
Bootstrap's grid is made up of 12 equal-sized columns. Each piece of content is aligned to this grid by specifying the number of columns to span.
The code to the right uses Bootstrap's grid to create a layout with two pieces of content.
Here each piece of content spans six columns, so it uses the .col-md-6
class.
Both columns are wrapped in a .row
class to create a horizontal group.
<ul class="nav nav-tabs">
<li><a href="#">Primary</a></li>
<li class="active"><a href="#">Social</a></li>
<li><a href="#">Promotions</a></li>
<li><a href="#">Updates</a></li>
</ul>
<ul class="nav nav-pills">
<li><a href="#">Primary</a></li>
<li class="active"><a href="#">Social</a></li>
<li><a href="#">Promotions</a></li>
<li><a href="#">Updates</a></li>
</ul>
By adding Bootstrap classes to your HTML elements, you can make use of Bootstrap's CSS to build your page faster. This lets you quickly set up the basic styles and layout so that you can get to the more interesting aspects of your page's design.
Bootstrap provides CSS for many more web components. Check out this site to see how else you can use Bootstrap to style your HTML elements!
make an Interactive Website 3 JavaScript (0) | 2014.08.22 |
---|---|
make an Interactive Website 2 Jquery coding (0) | 2014.08.22 |
make an Interactive Website 1 (0) | 2014.08.21 |
make website 3 coding (0) | 2014.08.21 |
make web site 1 by codecademy (0) | 2014.08.21 |