CSS에 대해 나는 깊은 지식이 없지만, 이런 것들을 알면 언젠가는 방법이 있을 것이다
15151 단어 JavaScript
저는 CSS에 대해 깊은 지식이 없지만 이런 것들을 알면 방법이 있을 거예요. 저는 일반적인 잡기장으로 필기를 하고 싶어요.
Layout
수평/수직 정렬
justify-content
align-items
미리 보기
Playgroundflex-start
center
liveweave center
center
liveweave flex-end
center
liveweave flex-start
flex-start
liveweave flex-start
flex-end
liveweave
TL;DR
- 한 행flex-direction: row
에서 컨텐츠 정렬
- justify-content
에 수평 방향 지정
- align-items
에서 수직 방향 지정하기<div>
<p></p>
<p></p>
<span></span>
<input placeholder="input"/>
<button>button</button>
</div>
/* コンテナ */
div {
display: flex;
flex-direction: row;
/* justify-content: flex-start | center | flex-end; */
/* align-items: flex-start | center | flex-end; */
}
/* 子要素間の左右マージン */
/* `*` が遅いらしいので実際使う時は button,p などに変更 */
div > * {
margin: 0 0.3em;
}
가로 격자 레이아웃
TL;DR
- grid-template-columns: repeat(3, 30%)
30% 너비의 열 3개 만들기
- grid-template-columns: 100px 90px 80px
열별로 폭을 지정할 수도 있습니다.
- grid-template-rows
면 열이 아닌 행이 같을 수 있음<div>
<article><img src="https://picsum.photos/id/237/200/300"/></article>
<article><img src="https://picsum.photos/id/1025/200/300"/></article>
<article><img src="https://picsum.photos/id/1062/200/300"/></article>
</div>
div {
display: grid;
grid-template-columns: repeat(3, 30%);
grid-gap: 3%;
}
Utility
드래그 앤 드롭을 통해 전체 요소 크기 조정
TL;DR
- resize
크기 조정 가능 <header>
<div>contents</div>
<div>contents</div>
<div class="resizable-h">resizable-h</div>
</header>
<nav class="resizable-v">resizable-v</nav>
.resizable-h {
min-width: 10em;
overflow: hidden; /* これがないとリサイズ効かない */
resize: horizontal; /* 横方向のリサイズ */
background: #516f8d;
}
.resizable-v {
min-height: 10em;
overflow: hidden; /* これがないとリサイズ効かない */
resize: vertical; /* 縦方向のリサイズ */
background: #516f8d;
}
dd의 빈 요소에서 기본적으로 연결 문자 보이기
TL;DR
- dd:empty
빈 컴포넌트를 결정합니다.<dl>
<dt>Artist</dt>
<dd>Queen</dd>
<dt>Title</dt>
<dd>Made in Heaven</dd>
<dt>Release date</dt>
<dd></dd> <!-- 空要素 -->
<dt>Review</dt>
<dd>this is the best Album</dd>
</dl>
dd:empty::before {
content: '-';
}
초점을 맞출 때 오류 알림 보이기
TL;DR
- focus-within
div 태그에 "하위 요소에 초점이 있을 때"CSS
- focus-visible
에서 포커스 루프 제거
- caret-color
에서 구 색상 변경<!-- FontAwesome 使用 -->
<div>
<i class="fa fa-user"></i>
<input type="text">
</div>
input {
caret-color: red;
}
/* 子要素がフォーカスを持つ時に適用される CSS */
div:focus-within i {
color: #f56161;
}
div:focus-within input {
border: 1px solid #f56161;
}
/* 影つけて強調 */
input:focus {
box-shadow: 2px 2px 2px 0 #f56161;
}
/* フォーカスリングを消す */
input:focus-visible {
outline: none;
}
라이브러리 팝업 대화상자를 사용하지 않음
TL;DR
- <dialog>
설정
- document.getElementById("id").showModal()
에서 대화상자 열기
-CSS에서 transition
사용하면 부스스한 느낌이 나요.<dialog id="dialog">
<!-- form がないとボタンが反応しないので必須 -->
<form method="dialog">
<p>これ便利じゃないですか?</p>
<!-- button の value が dialog.returnValue になる -->
<button value="yes">yes</button>
<button value="no">no</button>
</form>
</dialog>
<button id="trigger">Open dialog</button>
const $trigger = document.getElementById("trigger");
const $dialog = document.getElementById("dialog");
$trigger.addEventListener("click", () => {
$dialog.showModal();
});
$dialog.addEventListener("close", () => {
$result.value = $dialog.returnValue;
});
dialog {
/* opacity 効かせるために display 必須 */
display: block;
opacity: 0;
}
dialog[open] {
/* 2秒間かけて opacity を 0 > 1 に変化させる(フワッ) */
opacity: 1;
transition-property: opacity;
transition-duration: 2s;
transition-timing-function: ease;
}
Reference
이 문제에 관하여(CSS에 대해 나는 깊은 지식이 없지만, 이런 것들을 알면 언젠가는 방법이 있을 것이다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ringtail003/items/d18f746f3399a36ce1e6
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
<div>
<p></p>
<p></p>
<span></span>
<input placeholder="input"/>
<button>button</button>
</div>
/* コンテナ */
div {
display: flex;
flex-direction: row;
/* justify-content: flex-start | center | flex-end; */
/* align-items: flex-start | center | flex-end; */
}
/* 子要素間の左右マージン */
/* `*` が遅いらしいので実際使う時は button,p などに変更 */
div > * {
margin: 0 0.3em;
}
<div>
<article><img src="https://picsum.photos/id/237/200/300"/></article>
<article><img src="https://picsum.photos/id/1025/200/300"/></article>
<article><img src="https://picsum.photos/id/1062/200/300"/></article>
</div>
div {
display: grid;
grid-template-columns: repeat(3, 30%);
grid-gap: 3%;
}
드래그 앤 드롭을 통해 전체 요소 크기 조정
TL;DR
-
resize
크기 조정 가능 <header>
<div>contents</div>
<div>contents</div>
<div class="resizable-h">resizable-h</div>
</header>
<nav class="resizable-v">resizable-v</nav>
.resizable-h {
min-width: 10em;
overflow: hidden; /* これがないとリサイズ効かない */
resize: horizontal; /* 横方向のリサイズ */
background: #516f8d;
}
.resizable-v {
min-height: 10em;
overflow: hidden; /* これがないとリサイズ効かない */
resize: vertical; /* 縦方向のリサイズ */
background: #516f8d;
}
dd의 빈 요소에서 기본적으로 연결 문자 보이기
TL;DR
-
dd:empty
빈 컴포넌트를 결정합니다.<dl>
<dt>Artist</dt>
<dd>Queen</dd>
<dt>Title</dt>
<dd>Made in Heaven</dd>
<dt>Release date</dt>
<dd></dd> <!-- 空要素 -->
<dt>Review</dt>
<dd>this is the best Album</dd>
</dl>
dd:empty::before {
content: '-';
}
초점을 맞출 때 오류 알림 보이기
TL;DR
-
focus-within
div 태그에 "하위 요소에 초점이 있을 때"CSS-
focus-visible
에서 포커스 루프 제거-
caret-color
에서 구 색상 변경<!-- FontAwesome 使用 -->
<div>
<i class="fa fa-user"></i>
<input type="text">
</div>
input {
caret-color: red;
}
/* 子要素がフォーカスを持つ時に適用される CSS */
div:focus-within i {
color: #f56161;
}
div:focus-within input {
border: 1px solid #f56161;
}
/* 影つけて強調 */
input:focus {
box-shadow: 2px 2px 2px 0 #f56161;
}
/* フォーカスリングを消す */
input:focus-visible {
outline: none;
}
라이브러리 팝업 대화상자를 사용하지 않음
TL;DR
-
<dialog>
설정-
document.getElementById("id").showModal()
에서 대화상자 열기-CSS에서
transition
사용하면 부스스한 느낌이 나요.<dialog id="dialog">
<!-- form がないとボタンが反応しないので必須 -->
<form method="dialog">
<p>これ便利じゃないですか?</p>
<!-- button の value が dialog.returnValue になる -->
<button value="yes">yes</button>
<button value="no">no</button>
</form>
</dialog>
<button id="trigger">Open dialog</button>
const $trigger = document.getElementById("trigger");
const $dialog = document.getElementById("dialog");
$trigger.addEventListener("click", () => {
$dialog.showModal();
});
$dialog.addEventListener("close", () => {
$result.value = $dialog.returnValue;
});
dialog {
/* opacity 効かせるために display 必須 */
display: block;
opacity: 0;
}
dialog[open] {
/* 2秒間かけて opacity を 0 > 1 に変化させる(フワッ) */
opacity: 1;
transition-property: opacity;
transition-duration: 2s;
transition-timing-function: ease;
}
Reference
이 문제에 관하여(CSS에 대해 나는 깊은 지식이 없지만, 이런 것들을 알면 언젠가는 방법이 있을 것이다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ringtail003/items/d18f746f3399a36ce1e6텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)