월말평가 (머신러닝, 파이썬), css 기초
github 소스코드: https://github.com/YesolLee421/DaeguAISchool2021/tree/main/EX_3
<link>
태그 안 href 속성값으로 css파일 경로 넣어주기
<link rel="stylesheet" type="text/css" href="style.css">
<header>
<h1>hello World</h1>
</header>
header h1 { color: red; }
태그의 별명과 같은 것으로 하나의 태그가 여러 개의 클래스를 가질 수 있다. 한 문서 안에 동일 클래스 여러 개를 사용할 수 있다.
<header>
<h1 class="test1">hello World</h1>
<h2 class="test1 test2">welcome</h2>
</header>
.test1 { color: red; }
.test2 { background-color: pink;}
태그의 이름과 같은 것으로 하나의 태그가 하나의 id를 가질 수 있다. 한 문서 안에 하나의 id는 한 번만 쓸 수 있다. javascript 사용 시 id 이용 해 객체 지정할 때 중복 id가 있으면 가장 위 객체만 지정된다. id 이름값은 숫자로 시작할 수 없다.
<header>
<h1 id="test1">hello World</h1>
<h2 id="test2">welcome</h2>
</header>
#test1 { color: red; }
#test2 { background-color: pink;}
태그 속성 중 하나로 style="" 안에 다시 css 속성과 값을 넣어줄 수 있다. 선택자들 중 가장 우선적으로 적용된다.
<header>
<h1 style="color: gray;", id="test1">hello World</h1>
<!-- style 속성이 id보다 우선하여 글자색이 회색으로 적용됨-->
</header>
.test1 { color: red; }
여러 선택자들이 중복될 경우 적용되는 우선순위를 나타낸다. 원본 코드를 유지하면서 새로운 css 속성을 적용하고 싶을 때 유리하다.
<header id="intro">
<h1>header h1</h1>
<div class="container">
<h1>header h2</h1>
</div>
</header>
/*가장 윗 줄이 가장 디테일하게 요소를 가리키고 있으므로 <div>안 <h1>요소의 글자색은 빨간색이 된다. */
#intro .container h1{ color:red;}
#intro .container { color:blue;}
#intro { color:yellow;}
width
, height
color
: color name, 헥사코드, rgb(r,g,b)opacity
: 투명도. 0 = 완전 투명, 1 = 원래 색border
: 테두리 속성 (테두리 종류, 테두리 굵기, 테두리 색 등)border-radius
: 테두리 가장자리 둥글게 조절div {
width: 100%;
height: 300px;
min-width: 100px;
max-width: 800px;
opacity: 0.5;
border: 10px solid green;
border-radius: 30px;
background-color: pink;
}
font-family
: 여러 폰트 중 앞에서부터 사용가능한 폰트 적용<link>
(css 시트 경로 위에), css font-family
가져와서 적용 가능text-decoration
: underline, line-throughtext-align
: 태그의 bg color 범위 안에서 정렬됨font-style
: 글자 스타일 (기울임체 등)font-
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Jomhuria&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css">
h1 {
color: indigo;
font-size: 120px;
font-style: italic;
font-family: 'Jomhuria', sans-serif;
font-weight: 500;
text-decoration: underline;
text-align: center;
background-color: hotpink;
}
<ul>
<ol>
리스트 스타일list-style
속성값으로 none을 준다.ul {list-style: none;}
background-image
: image보다 큰 공간이면 반복해서 채움background-repeat
: 이미지 반복 방식 제어background-position
: 이미지 위치 제어<div id="bg"></div>
<img src="icon.png" alt="코드 아이콘" width="100px" height="50px"> -->
#bg {
width: 256px;
height: 256px;
background-color: yellowgreen;
background-image: url(icon.png);
background-repeat: no-repeat;
background-position: left center;
}
<img>
의 차이alt
속성값으로 이미지 정보를 적을 수 있기 때문에 웹 접근성을 고려해 로고 등 정보를 제공하는 이미지는 <img>
태그를 사용한다.소스코드: https://github.com/YesolLee421/DaeguAISchool2021/tree/main/EX_2 ->naver.html, style-naver.css
오늘 첫 월말평가를 치뤘다. 지난 2주 간 배운 파이썬과 머신러닝 관련 내용이었는데, 딱히 인터넷 검색을 하지 않아도 그렇게 어렵진 않았다. 덕분에 지난 2주간 배운 내용을 다시 한 번 돌아보게 되어 도움이 되었다.
어제 html 설계도면 작성의 경우 콘텐츠를 넣지 않으면 브라우저 상 변화가 잘 보이지 않았는데, css는 속성값이 변경될 때마다 바로바로 변화가 보여서 더 재밌었다. 강의가 길지 않아서 연습 삼아 어제 배운 html설계도에 css를 추가해 보았다. 아직 흔히 보는 웹사이트의 디자인과는 거리가 멀지만 언젠가 할 수 있게 되기를 바란다.