Skip to content

”Webサイトの見た目を整える”改訂、高度なCSSと統合。。OKなら"高度なCSS"は消します#498

Merged
RRRyoma merged 27 commits into
masterfrom
website-no-mitame
Oct 21, 2023
Merged

”Webサイトの見た目を整える”改訂、高度なCSSと統合。。OKなら"高度なCSS"は消します#498
RRRyoma merged 27 commits into
masterfrom
website-no-mitame

Conversation

@RRRyoma
Copy link
Copy Markdown
Contributor

@RRRyoma RRRyoma commented Oct 20, 2023

No description provided.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Oct 20, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2012fb2
Status: ✅  Deploy successful!
Preview URL: https://1087e313.utcode-learn.pages.dev
Branch Preview URL: https://website-no-mitame.utcode-learn.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@chvmvd chvmvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとう。

Comment thread docs/1-trial-session/12-css/begin-css.png
Comment thread docs/1-trial-session/12-css/selector.png
Comment thread docs/1-trial-session/12-css/index.md Outdated
Comment thread docs/1-trial-session/12-css/index.md
Comment thread docs/1-trial-session/12-css/index.md Outdated
### セレクタとID

```html title="index.html"
Hello, <strong id="world">World</strong>!
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは意味論的によくなさそう。

Worldを強調するために、文字色を赤色にしたいのだと思う。
だけど、このコードが表す意味は、まずWorldを強調する。さらに、Worldという文字自体が特殊でそれ自体を赤くして強調するという意味になっちゃう。

Worldを強調するために、文字色を赤色にしたいのなら、id属性はなしでstrong要素に対して文字色を赤にする方が良さそう。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これは確かスライドレビューの時に
strong要素が全部赤色になるよりこれだけをidで指定して赤色にしたほうがいいよね、トいう結論になった気がします。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

それはidを使わせる練習にならないから、授業スライドでもidを決めさせるという話になってました

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

それは、HTML側を変えればいいのでは?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<p id="greeting">Hello World!</p>

とか?

Comment thread docs/1-trial-session/12-css/index.md
Comment thread docs/1-trial-session/12-css/index.md Outdated
Comment thread docs/1-trial-session/12-css/index.md Outdated
Comment thread docs/1-trial-session/12-css/index.md Outdated
Comment thread docs/1-trial-session/12-css/index.md Outdated
Copy link
Copy Markdown
Contributor

@chelproc chelproc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

日本語と英語の間にはスペース1文字分あけましょう

Comment thread docs/1-trial-session/12-css/index.md Outdated
import ViewSource from "@site/src/components/ViewSource";

多くの<Term type="element">HTML 要素</Term>は、<Term strong type="styleAttribute" strong>style 属性</Term>を用いることで、その見た目を細かくカスタマイズすることができます。
多くの<Term type="element">HTML 要素</Term>は、<Term type="css">CSS</Term>を用いることで、その見た目を細かくカスタマイズすることができます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「CSSとはなんぞや」の話を冒頭に入れましょう。HTML、CSSとの関連性も

Comment thread docs/1-trial-session/12-css/index.md Outdated
多くの<Term type="element">HTML 要素</Term>は、<Term type="css">CSS</Term>を用いることで、その見た目を細かくカスタマイズすることができます。

## <Term type="styleAttribute">style 属性</Term>
## <Term type="css">CSS</Term>用のファイルを作成する
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CSS「用の」ファイル

「用の」が何をさしているかわからないです。「CSS ファイル」で十分ですね

Comment thread docs/1-trial-session/12-css/index.md Outdated
## <Term type="css">CSS</Term>用のファイルを作成する

`p` <Term type="element">要素</Term>の <Term type="styleAttribute"><code>style</code> 属性</Term>に `color: red;` を指定します。
CSS ファイルの拡張子は通常 `.css` です。今回は `index.html` と併せて `style.css` を作成しました。CSSの書き方を勉強して、`World`の文字を赤くしてみましょう。先に完成コードを下に示しておきます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 「勉強して」が少々口語的です。
  • 「完成コード」という言い方は普通しないです。「次の例では、Hello WorldWorld の部分を赤色にしています。」くらいでどうでしょうか。
  • またコードを示すときにスクリーンショットだけだと不親切なので、必ずコピーできるコードブロックも含めた方がいいですね。あと CodeSandbox も欲しいです
  • スクリーンショットの解像度が低いかと思います。スクリーンショットを撮る時は、Electron アプリやブラウザアプリであれば Ctrl + + で拡大できるのでその状態で取るといいです。高解像度モニタを持っている場合は OS のスケーリング設定を 200% とかにして撮影するといいと思います。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

対応しました

Comment thread docs/1-trial-session/12-css/index.md Outdated

## CSSの書き方

### link属性
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • link 要素
  • link はインラインコードにしましょう

Comment thread docs/1-trial-session/12-css/index.md Outdated
```

<ViewSource url={import.meta.url} path="_samples/first-css" />
まず注目すべきは `link` 要素です。HTMLファイルで、`link` 要素の `href` 属性を指定することにより、外部の CSS ファイルを読み込ませることができます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML ファイル -> HTML の方が正確かと思います

Comment thread docs/1-trial-session/12-css/index.md Outdated
</Answer>

:::tip HTMLの<Term type="styleAttribute">`style` 属性</Term>
`style.css`を作らずとも、HTMLファイル内に直接CSSを書き込むこともできます。例えば、`p` <Term type="element">要素</Term>の <Term type="styleAttribute"><code>style</code> 属性</Term>に `color: red;` を指定します。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTMLファイル -> HTML
「書き込む」-> 「指定する」
color: red; を指定します。」-> 指定することでどうなる?

Comment thread docs/1-trial-session/12-css/index.md Outdated

<ViewSource url={import.meta.url} path="_samples/first-css" />

「このプログラムを実行する」を押すと解るとおり、<Term type="styleAttribute">style 属性</Term>を指定した<Term type="element">要素</Term>内のテキストが赤色で表示されます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「このプログラムを実行する」を押すと解るとおり -> このプログラムを実行すると

Comment thread docs/1-trial-session/12-css/index.md Outdated

「このプログラムを実行する」を押すと解るとおり、<Term type="styleAttribute">style 属性</Term>を指定した<Term type="element">要素</Term>内のテキストが赤色で表示されます。

しかし、この方法ではHTML要素に逐一CSSを書きこむ必要があるため、HTMLが大きくなると大変になります。さらに、社会の要求の高まりに応えて CSS のプロパティの種類は増え続け、現在では数えきれないほどのプロパティが定義されています。このため、CSS をすべて<Term type="styleAttribute">`style` 属性</Term>で記述するのは現実的ではありません。数が多すぎて、見通しが悪くなってしまうからです。このため、通常 CSS ファイルは HTML ファイルとは別に用意されます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「逐一」->「スタイルを設定したい全ての HTML 要素に」
「CSSを書き込む」 -> 「style 属性を指定する」
「HTMLが大きくなると大変」->「HTML 要素の数が多くなると見通しが悪くなります。」 また後半部分と内容がかぶっているので修正

プログラムは非常に重要なものなので、「大変だから」という理由でプログラムの書き方を変えることはいかなる場合でも許されません。「大変」なだけであれば、エディタによる支援を入れれば解決できます。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「しかし、 style 属性で HTML と CSS をごちゃ混ぜに書くよりも、 HTML は「構造」、 CSS は「スタイル」と役割をはっきり分離させておけば、コードの可読性が上がったり、後から修正するのも簡単です。このため、通常 CSS ファイルは HTML ファイルとは別に用意されます。」に直してみました

Comment thread docs/1-trial-session/12-css/index.md Outdated

## 初級課題2

下のような、文字色が緑、背景色が好きな色(この例では黒)の`Hello, CSS!`をブラウザで表示してみましょう。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

カッコは前後にスペースを入れます。
英語と同じですね

Comment thread docs/1-trial-session/12-css/index.md Outdated
しかし、この方法ではHTML要素に逐一CSSを書きこむ必要があるため、HTMLが大きくなると大変になります。さらに、社会の要求の高まりに応えて CSS のプロパティの種類は増え続け、現在では数えきれないほどのプロパティが定義されています。このため、CSS をすべて<Term type="styleAttribute">`style` 属性</Term>で記述するのは現実的ではありません。数が多すぎて、見通しが悪くなってしまうからです。このため、通常 CSS ファイルは HTML ファイルとは別に用意されます。
:::

## CSSのプロパティ
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

課題の後に新情報を入れない

`p` <Term type="element">要素</Term>の <Term type="styleAttribute"><code>style</code> 属性</Term>に `color: red;` を指定します。

CSS の書き方を学び、`World`の文字を赤くしてみましょう。
![Hello World!](./red-hello-world.png)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

画像の前後には空行を!(次の画像もです)

Comment thread docs/1-trial-session/12-css/index.md Outdated

CSS ファイルの拡張子は通常 `.css` です。今回は `index.html` と併せて `style.css` を作成しました。
![CSSを書き始める](./begin-css.png)
次の例では、<code>Hello World</code> の <code>World</code> の部分を赤色にしています。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前後に改行をあけたら普通にバッククォーとでかけると思います。

Comment thread docs/1-trial-session/12-css/index.md Outdated
<ViewSource url={import.meta.url} path="_samples/first-css" />

次のように、<Term type="styleAttribute">style 属性</Term>を指定した<Term type="element">要素</Term>内のテキストが赤色で表示されます。
### <code>link</code> 要素
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

インラインコードブロックはバッククォートで
かけます

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

セレクタは #world なので矢印がセレクタというわけではないですね

Comment thread docs/1-trial-session/12-css/index.md Outdated

このプログラムを実行すると分かるとおり、<Term type="styleAttribute">style 属性</Term>を指定した<Term type="element">要素</Term>内のテキストが赤色で表示されます。

しかし、 <code>style</code> 属性で HTML と CSS をごちゃ混ぜに書くよりも、 HTML は「構造」、 CSS は「スタイル」と役割をはっきり分離させておけば、コードの可読性が上がったり、後から修正するのも簡単です。このため、通常 CSS ファイルは HTML ファイルとは別に用意されます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • HTML が「構造」、CSS が「見た目」であることは、別ファイルにしてもしなくても変わりません。
  • 「〜よりも」に呼応する部分がないです。「AよりもB(のほうが/は)C」が基本形かなと
  • 「〜たり」を使ったらもう一つ「〜たり」を入れる
  • 「ごちゃ混ぜ」->もっと文語的な表現がありそうかも?

Comment thread docs/1-trial-session/12-css/index.md Outdated

<ViewSource url={import.meta.url} path="_samples/first-css" />

このプログラムを実行すると分かるとおり、<Term type="styleAttribute">style 属性</Term>を指定した<Term type="element">要素</Term>内のテキストが赤色で表示されます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「〜するとわかるとおり」は冗長じゃないですかね?「このプログラムを実行すると」だけで十分では?

Comment thread docs/1-trial-session/12-css/index.md Outdated
## <Term type="styleAttribute">style 属性</Term>に指定できる値

前項で <Term type="styleAttribute">`style` 属性</Term>に指定した値を詳しく見ていきましょう。
外部のファイルに記述された CSS では、その CSS を適用する要素を明示的に指定する必要があります。準備として、まず CSS を適用したい HTML 要素にIDを付けます。(上の例では、 <code>index.html</code> の 9行目)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「外部のファイルに記述された」が 「CSS」を限定修飾しているように読めます。多分今までの教材の名残です。まだインラインCSSには触れていないので、非限定な書き方をするといいと思います。また、id 属性以外の方法もあることが分かりづらいです。
また HTML の id 属性を ID と呼ぶことはあまりない気がします。id 属性と言ってあげるのがいいんじゃないでしょうか。
「CSS を記述する際には、まずスタイルを適用する対象となる HTML 要素を指定する必要があります。このために用いることができるのが、HTML 要素の id 属性です。」と言った感じででどうでしょう。

:::

## 複数のプロパティ
```css title="style.css"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1行開ける

Comment thread docs/1-trial-session/12-css/index.md Outdated
<link rel="stylesheet" href="style.css" />
```

まず注目すべきは `link` 要素です。HTML で、`link` 要素の `href` 属性を指定することにより、外部の CSS ファイルを読み込ませることができます。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この書き方だと link 要素の href 属性さえ指定すれば CSS が読み込めるように読めます。実際は rel="stylesheet" 以外もあるので少し情報が足りません。
ただ厳密に書く必要もないので、「HTML の link 要素を用いることにより」くらいの表現でどうでしょう

Comment thread docs/1-trial-session/12-css/index.md Outdated
color: red;
![セレクタ](selector.png)

そして、CSS 側に書くのが **セレクタ**です。上の例では 、 <code>style.css</code> 1行目の`#world` がセレクタで、「`id` 属性が `world` である要素」を示します。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「でわ」と「、」の間にスペースが?

@RRRyoma RRRyoma merged commit 4df8a30 into master Oct 21, 2023
@RRRyoma RRRyoma deleted the website-no-mitame branch October 21, 2023 10:45
Copy link
Copy Markdown
Contributor

@chvmvd chvmvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この2つを直してプルリクエスト送ります!

Comment thread docs/1-trial-session/12-css/index.md
Comment thread src/components/Term/definitions.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants