Django - blog 홈페이지 5 (stylesheet-1)

yunseul·2024년 6월 17일

Django

목록 보기
25/30

stylesheet

제목 영역에 배경색을 넣고 글자 크기 등을 정하는 CSS 파일 코딩

CSS 파일의 이름 : base.css

### 위치 이동
cd /Users/user/test/django/project/web/web

### settings.py
vi settings.py

---

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/

STATIC_URL = '/static/'

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]           # 추가 (제일 하단)
  • 프로젝트 템플릿 디렉터리 처럼 CSS 파일과 정적 파일 또한 특정 디렉터리에 위치시켜야 함

base.css 생성

### 위치 이동
cd /Users/user/test/django/project/web

### 디렉토리 생성
mkdir -p static/css

### 위치 이동
cd /Users/user/test/django/project/web/static/css

### base.css
vi base.css

---

body {
    font-family: "Lucida Grande", Verdana, Arial, sans-serif;
    font-size: 12px;
}

/* PAGE STRUCTURE */
div#header {
    position: absolute;
    top: 0px;
    left: 0px;
    height: 30px;
    width: 100%;
    display: table;
    background: orange;
}

div#menu {
    position: absolute;
    top: 30px;
    left: 0px;
    height: 20px;
    width: 100%;
    display: table;
    table-layout: fixed;
    border-spacing: 40px 0px;
    background: #ffa;
    font-size: 8px;
}

div#content {
    position: absolute;
    top: 70px;
    left: 50px;
    right: 50px;
}

div#footer {
    position: absolute;
    bottom: 20px;
    left: 50px;
    right: 50px;
    height: 30px;
    border-top: 1px solid #ccc;
}

/* HEADER */
.maintitle {
    display: table-cell;
    vertical-align: middle;
    padding-left: 20px;
    color: #ffc;
    font-weight: bold;
    font-size: 16px;
}

.welcome {
    display: table-cell;
    vertical-align: middle;
    text-align: right;
    padding-right: 20px;
    color: #ffc;
    font-weight: normal;
    font-size: 12px;
}

.welcome a:link, .welcome a:visited {
    color: white;
}

/* MENU */
div#menu a:link, div#menu a:visited {
    color: #36c;
}

div#menu > li {
    display: table-cell;
    vertical-align: middle;
    border: 2px solid # bbb;
    border-radius: 25px;
    text-align: center;
    font-weight: bold;
}

/* pulldown menu */
div#menu li ul {
    display: none;
    position: absolute;
    margin: 0;
    padding: 10px 10px 5px 10px;
    list-style: none;
    border-right: 1px solid #ccc;
    border-left: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    background: white;
    z-index: 1;
}

div#menu li:hover ul {
    display: block;
}

/* LINK */
a:link, a:visited {
    color: 369;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* TABLE */
table {
    border-collapse: collapse;
}

td, th {
    line-height: 18px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    padding: 5px 15px;
    font-family: "Lucida Grande", Verdana, Arial, sans-serif;
}

참고 자료

profile
새로운 것을 시도하고 도전하는 것을 좋아하는 Engineer 입니다..

0개의 댓글