位置の調整はposition
親要素にposition:relative
該当要素にposition: absolute;
top: 100;
right: 20;
z-index: 10; 必要なら大きいのが上
CSSのpositionを総まとめ!absoluteやfixedの使い方は? (saruwakakun.com)
中央寄せ
文字を中央寄せしたいなら外のブロック要素に「text-align:center」
ブロック要素自体をしたいなら 「margin-left:auto; margin-right:auto;」
paddingにautoは指定不可、margin: autoの中央寄せの微調整はpaddingで
widthプロパティの初期値はauto (横いっぱいに広がっているのでwidthを入れる)
inlineの要素では、widthとheightの指定不可
padding: 0px; 50px; 0px; 0px;
テーブルの幅指定
複数テーブルのレイアウト整合はtr width%指定とtd/tr nowrapを細かくすればなんとかなる
AJAX
JS fetchで
【CSS】colorが効かない/文字色が変わらない原因と修正方法 (csshtml.work)
点数制、同点なら後述が勝つらしい
■CSSアニメーション
transition に時間を入れておき、JSでclassをremoveしたりaddする
変化にその時間分を掛ける動作となる
 now_classからfuture_classの2つをCSSで作り、JSでremoveやaddをする
[B! css] 2022年のモダンCSS改 (hatena.ne.jp)
中央揃え
.container{
  display: flex;
  justify-content: center;
  align-items: center;
}
.container{
  display: grid;
  justify-content: center;
}
アンカーリンク移動をスムーズにする
html {
  scroll-behavior: smooth;
}
スクロールで位置をずらすトップからのマージン
section {
  scroll-margin-top: 60px;
}
すりガラス
.box{
  backdrop-filter: blur(8px);
  background-color: rgba(255, 255, 255, 0.5);
}
1行でも両端ぞろえ
th{
  text-align-last: justify;
}
ナビがfixedの場合の本部のスクロール連動をなくす
.navi{
  overscroll-behavior-y: contain;
}
++++++++++++++++++
2020-03-01 wrote
Gridは悪名高いテーブルレイアウトと考え方がまるで同じ
CSSの方が糞であったであろう、テーブルこそが発明でしょうに、セマンティック?
containerにdisplay: grid か flex か table を指定するので直接の要素には混在不可、入れ子なら可
https://ics.media/entry/15921/
■CSS grid
https://qiita.com/kura07/items/e633b35e33e43240d363
https://qiita.com/kura07/items/486c19045aab8090d6d9
 ページ全体のレイアウト、グリッドレイアウト
 コンテナを作り、グリッドに名前を付けて、割り当てる
 <section class="container">
  <div class="visual">(メインビジュアル)</div>
  <div class="number">(数字)</div>
  <div class="expression">(テキスト)</div>
  <div class="other">(3枚の写真)</div>
 </section>
 .container {
  display: grid;
  grid-template:
   "visual number expression" 1fr
   "visual other other" 220px /
   40% 120px 1fr;
 }
 .visual {
  grid-area: visual;
 }
 @media (max-width: 800px) {
  .container {
   grid-template:
   "visual visual" 100vw
   "number expression" 1fr
   "other other" auto /
   120px 1fr
  }
 }
■Flexbox
https://www.webcreatorbox.com/tech/css-flexbox-cheat-sheet
https://qiita.com/junya/items/7762da8052d86462f232
 縦横揃え、可変サイズ、でも複数配置が駄目、1行の並び
  justify-content
  align-items
  flex-grow
  flex-shrink
 .container {
  display: flex;
  justify-content: center;
  align-items: center;
 }
■display: table / display: table-cell
https://techacademy.jp/magazine/19415
https://app.codegrid.net/entry/css-table-1
https://www.yoheim.net/blog.php?q=20150102
https://nxpg.net/blog/tech/?p=10764
CSSのvertical-alignが効かない縦並び(display:gridの中にdisplay:tableの中にdisplay:table-cell)
#container{
 display: grid;
 grid-template-rows: 25px 1fr;
 grid-template-columns: 300px 1fr 200px;
}
#column_right{
   grid-row: 2;
 grid-column: 3 / 4;
 display: table;
}
#area{
 background-color: #eee;
 width: 150px;
 height: 150px;
 text-align: center;
 display: table-cell;
 vertical-align: middle;
}
<div id="container">
  <div id="navi_left">...</div><div id="navi_right">...</div>
  <div id="contents">...</div><div id="area">...</div>
</div>
■Float
 テキストの回りこみ
 .leftBox {
     width: 45%;
     float: left;
 }
Floatレイアウト
https://www.bangboo.com/cms/blog/page_18.html
Padding/Float/Height100%の問題
https://www.bangboo.com/cms/blog/page_184.html
■object-fit
 画像の比率
 img {
  object-fit: cover;
 }
 .image1 {
  object-position: 30% 40%;
 }
■その他
spanタグにline-heightを設定しても行間は設定できない、display:block;を追加するか親で設定する
ボックス要素のセンタリング(中のテキストは左寄せ)
 <div style="width:500px"><div style="text-align:left; display:inline-block;">
 https://qiita.com/KAMEch/items/b52c5e23212b8fef81a7
 https://www.granfairs.com/blog/staff/centering-by-css
リストのマーカの位置に迷った
ulのpadding-leftが外側からマーカの右側迄の距離で15pxとかは必要
liのpadding-leftはマーカの右からから先頭文字までの距離で0px等で良い
https://maku77.github.io/web/layout/list-margin.html
2019見直したいCSS,Javascript
https://speakerdeck.com/tonkotsuboy_com/2019nian-madenijian-zhi-siteokitai-cssjavascriptfalseshou-fa
CSSレイアウト再入門:完全に理解してCSSを記述するために - Speaker Deck
実例で学ぶFlexboxとCSS Gridの使い分け – TAKLOG (tak-dcxi.com)
2024年、Web制作者がチェックしておきたいCSSの新機能のまとめ | コリス




  
