footerを最下部に表示する

footer {
	position: fixed;
	bottom:0px;
	width: 100%;
	height: 30px;
	padding-top: 10px;
	padding-bottom: 10px;
	background: #483d8b;
	text-align: center;
	color: #fff;
}

なるほど、position:fixed; とwidth:100%, height: npx;ね

loginページを作っていこう

<!DOCTYPE html>
<html>
  <head>
  	<meta charset="utf-8">
    <title>ログイン</title>
    <link rel="stylesheet" href="asset/css/style.css">
    <script src=""></script>
  </head>
  <body>
  	<h1>ZEUS</h1>
    <div id="content">
  	<p>ログイン画面</p>
  	<form action="" method="post">
      <p>ログインID:<input type="text" name="login" size="40"></p>
      <p>パスワード:<input type="text" name="password" size="40"></p>
    </form>
  	<p>ログインID・パスワードをお忘れの方は<a href="">こちら</a><br>
  	   アカウントをお持ちでない方は<a href="">こちら</a></p>
    </div>
  	<footer>
  		hpscript
  	</footer>
  </body>
</html>
body {
	margin:0px;
	#content{
		margin-right: 50px;
		margin-left: 50px;
	}	
}
h1 {
	text-align: center;
}
footer {
	padding-top:5px;
	padding-bottom:5px;
	background: #483d8b;
	text-align: center;
	color: #fff;
}

なんじゃこりゃ、すげー時間かかるやんけ。日頃全くコーディングしていないのがばれる。

sassを使っていく

3.5.7が入っています。
[vagrant@localhost front]$ sass -v
Ruby Sass 3.5.7

gemをアップデートします。
$ gem update –system
RubyGems system software updated

$ gem update sass
新しいsassは3.6.0のようですね。

Successfully installed sass-3.6.0

sass

body {
	color: blue;
}

$ sass –watch style.scss:style.css
あれ、gulp必要ない?

login.php

<?php
?>
<!DOCTYPE html>
<html>
  <head>
  	<meta charset="utf-8">
    <title>ログイン</title>
    <link rel="stylesheet" href="asset/css/style.css">
    <script src=""></script>
  </head>
  <body>
  	<h1>ログイン画面</h1>
  	<p></p>
  </body>
</html>

sassまではok♪
では、コーディングしていきましょう。

gulpで Use of const in strict mode.

node.jsのバージョンが低いのが原因
node.js 10.7.0を使って、gulpをもう一度実行します。

[vagrant@localhost front]$ node -v
v0.10.48
[vagrant@localhost front]$ nvm use 10.7.0
-bash: nvm: コマンドが見つかりません
[vagrant@localhost front]$ source ~/.nvm/nvm.sh
[vagrant@localhost front]$ nvm ls
-> v10.7.0
system
default -> 10.7.0 (-> v10.7.0)
node -> stable (-> v10.7.0) (default)
stable -> 10.7 (-> v10.7.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/carbon (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.14.3 (-> N/A)
lts/carbon -> v8.11.3 (-> N/A)
[vagrant@localhost front]$ nvm use 10.7.0
Now using node v10.7.0 (npm v6.1.0)
[vagrant@localhost front]$ node -v
v10.7.0
[vagrant@localhost front]$ gulp
[21:12:57] Using gulpfile ~/local/front/gulpfile.js
[21:12:57] Starting ‘html’…
[21:12:57] Finished ‘html’ after 14 ms
[21:12:57] Starting ‘img’…
[21:12:57] Finished ‘img’ after 7.34 ms
[21:12:57] Starting ‘default’…
[21:12:57] Finished ‘default’ after 40 μs
[21:13:01] gulp-imagemin: Minified 1 image (saved 1.48 kB – 11.1%)

OK!

で、何やるのって、sassのコンパイルをgulpで自動化したいのでござる。

gulp 二つのタスクを実行

gulp.task defaultでmsgであとに実行したい処理を書いて、そのgulp, taskでfunctionの前に呼び出す。

var gulp = require('gulp');

gulp.task('html', function(){
	return gulp.src('./src/*.html')
		.pipe(gulp.dest('./dest'))
});

gulp.task('msg', ['html'], function(){
	console.log('hello');
});

gulp.task('default', ['msg']);

[vagrant@localhost front]$ gulp
[20:15:16] Using gulpfile ~/local/front/gulpfile.js
[20:15:16] Starting ‘html’…
[20:15:16] Finished ‘html’ after 14 ms
[20:15:16] Starting ‘msg’…
hello
[20:15:16] Finished ‘msg’ after 40 μs
[20:15:16] Starting ‘default’…
[20:15:16] Finished ‘default’ after 10 μs

gulp default

var gulp = require('gulp');

gulp.task('hello', function(){
	console.log('hello world');
});

gulp.task('default', ['hello']);

[vagrant@localhost front]$ gulp
[20:04:00] Using gulpfile ~/local/front/gulpfile.js
[20:04:00] Starting ‘hello’…
hello world
[20:04:00] Finished ‘hello’ after 126 μs
[20:04:00] Starting ‘default’…
[20:04:00] Finished ‘default’ after 13 μs

copy & paste は.srcと.pipe

var gulp = require(‘gulp’);

gulp.task(‘html’, function(){
gulp.src(‘./src/*.html’)
.pipe(gulp.dest(‘./dest’))
});

gulp.task(‘default’, [‘html’]);
[/html]

gulpfile.jsでコマンドを実行

gulpfile.js

var gulp = require('gulp');

gulp.task('hello', function(){
	console.log('hello world');
});

[vagrant@localhost front]$ gulp hello
[17:18:28] Using gulpfile ~/local/front/gulpfile.js
[17:18:28] Starting ‘hello’…
hello world
[17:18:28] Finished ‘hello’ after 77 μs

おおお、なんかすげー。gulp.taskでタスクを書いていくようですね。

カレントでgulpをインストール

sudo npm config set strict-ssl false
sudo npm install –save-dev gulp
sudo npm config set strict-ssl true

package.json

{
  "name": "front",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "BSD",
  "devDependencies": {
    "gulp": "~3.9.1"
  }
}

ちなみに、node.modulesがなくてもnpm installでpackage.jsonの中身をインストールすることができる。

projectのpackage.jsonを作る

[vagrant@localhost front]$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sane defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install –save` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
name: (front) front
version: (0.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (BSD)
About to write to /home/vagrant/local/front/package.json:

{
“name”: “front”,
“version”: “0.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo \”Error: no test specified\” && exit 1″
},
“author”: “”,
“license”: “BSD”
}

Is this ok? (yes)

[vagrant@localhost front]$ ls
package.json

package.jsonが入りました。中身を観ると、コマンドラインと一緒ですね。

{
  "name": "front",
  "version": "0.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "BSD"
}