LoginSignup
0
0

More than 1 year has passed since last update.

忘れっぽいシリーズ(ジブンヨウ)

Last updated at Posted at 2019-07-26

HTML

エスケープ文字

半角スペース

 

CSS

1文字目字下げ

text-indentで字下げする。
emは1文字分といった意味です。

text_indent.css
 p {
    text-indent: -1em;
 }

上下中央

vertial-alignやmerginなどで上下中央できない場合はこれを使う!
transformで-50%してあげることで、どんなサイズであっても真ん中になる。

test.css
 .parent {
    position: rerative;
 }

 .parent .child {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
     -webkit- transform: translateY(-50%);
 }

上下左右中央

test.css
 .parent {
    position: rerative;
 }

 .parent .child {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateY(-50%) translateX(-50%);
     -webkit- transform: translateY(-50%) translateX(-50%);
 }

テキストを両端揃え

text-align-last: justify;

IE・Edgeは
text-justify: inter-ideograph;

Safariはどちらも非対応のため、別のスタイルにしたほうが良い。

1文字目指定

:first-letter

buttonタグのフォーカス時の線やら影を消す。

outline: 0;

四角の上辺・下辺のみを角丸にする。

border-radius: 4px 4px 0 0;
border-radiusのプロパティは左上右上右下左下の順番で指定していく。
上記の例は上辺のみを角丸としている。

CSSセレクタ

classやidが付与されているやつだけセレクタ

selectar.css
p[class]{
    padding: 0;
}
p[id]{
    padding: 0;
}

/*付与されていないもの*/
p:not([class]){
    padding: 0;
}
p:not([id]){
    padding: 0;
}

js(jQuery)

スマホでのクリックイベントの発火

touchstarttouchendを使うとiosでもクリックでの発火ができる。
かつイベントハンドリングを$(document)とすることでAndroidも機能する。

処理終了

exit(返しなし)
return

Sublime便利シリーズ

HTMLタグを正規表現で検索

<([^"'>]|"[^"]*"|'[^']*')*>

コメントアウトを検索

<!([^"'>]|"[^"]*"|'[^']*')*>

空行を検索

^\n

PHP

エスケープ

\

PHPでHTMLゴニョゴニョ

スクレイピング

HTMLタグ生成の注意

シングクォーテーションで全体を囲む
それでないとタグの中間にあるダブルクォーテーションなどを誤認してしまい、誤作動を起こす。

配列に変数を追加

[].php
<?php
//宣言
$hoge[];

$hoge[] = "タカ";
$hoge[] = "トラ";
$hoge[] = "バッタ";

var_dump($hoge);
//=>array(3) { [0]=> string(2) "タカ" [1]=> string(2) "トラ" [2]=> string(3) "バッタ" }
?>

時間計算

time.php
<?php
 $time = new DateTime();

 //日本時刻
 $time->setTimeZone(new DateTimeZone('Asia/Tokyo'));
 $time = $dt->format('Y/m/d H:i:s');
 print "日本時刻→" . $time;

if( strtotime(date('Y-m-d H:i')) < strtotime('2019-1-1 9:00') ){
    // 2019-1-1 8:59以前の処理
    print "time日本:$time";
}
?>

配列内検索

in_array.php
<?php
$array = ["タカ","クジャク","コンドル"];

$result = in_array("タカ", $array);
var_dump( $result );
// bool(true)

$result = in_array("トラ", $array);
var_dump( $result );
// bool(false)
?>

日付(月末・月2桁表示)

day.php
<?php

// 月末表示 2019/1/31
echo date('Y/n/t');

// 月2桁表示 2019/01
echo date('Y/m');

?>

SVG

preserveAspectRatio="none"
svg画像を縦横比無視で可変にする魔法のコトバ

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0