CSS (30)

 

둥근 토글 버튼

본 포스팅에서는 html, css, javascript를 이용하여 둥근 toggle버튼을 만들고, 버튼의 상태가 변경될 때마다 상태를 출력하는 기능까지 만들어 봅니다. 본 보스팅에 사용되는 기본코드는 w3schools에서 가지고 온 것입니다. w3schools에서는 단순히 css를 이용해서 토글버튼처럼 보이는 것을 만드는 것 까지만 보여주었는데, 저는 그렇게 토글이 될 때마다 자바스크립트를 이용해서 어떤 기능이 실행되는 부분까지 확장해서 포스팅합니다.

 

우선 toggle.html 파일에 input tag를 이용해서 아래와 같이 작성해줍니다.

<!DOCTYPE html>
<html>

<head>
</head>

<body>
    <label class="switch">
        <input type="checkbox" />
        <span class="slider round"></span>
    </label>
</body>

</html>

 

그리고 toggle.css 파일을 하나 만들어서 그 안에 아래와 같이 작성을 해줍니다.

/* 슬라이더 외부를 감싸는 라벨에 대한 스타일 */
.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

/* HTML 기본 체크박스 숨기기 */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* 슬라이더 - 실제로 토글될 부분 */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: #2196F3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

/* 슬라이더를 동그랗게 보여주기 위한 부분 */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

 

이제 HTML 파일의 <head></head> 부분에 위 css 파일을 링크시켜줍니다.

<head>
	<link rel="stylesheet" type="text/css" href="toggle.css" />
</head>

 

이제 toggle.html 파일을 더블클릭해서 브라우저에서 열어보면 아래 영상처럼 움직이는 것을 확인할 수 있습니다.

 

둥근 토글 버튼 움직이는 영상

 

자, 이제 여기에 자바스크립트를 이용하여 기능을 추가해보도록 할건데요,

이 토글버튼은 input 태그의 checkbox를 이용한 것이므로 토글이 될 때마다 checked 속성이 변경되도록 되어있습니다.

이 기본적인 내용을 기억하고 자바스크립트에서 토글버튼의 checked 속성을 기반으로 특정 문자열을 출력하도록 해보겠습니다.

자바스크립트 파일은 따로 만들지 않고 그냥 html 파일에 추가하도록 할게요.

우선, input 태그에 onclick 속성을 이용하여 toggle이라는 함수를 호출하도록 하고, toggle 함수를 구현하겠습니다.

아래처럼 input  태그의 onclick 속성을 넣어주세요. 

<label class="switch">
    <input type="checkbox" onclick="toggle(this)">
    <span class="slider round"></span>
</label>

이렇게 해주면 토글버튼(체크박스)가 클릭될 때마다 toggle이라는 함수를 호출하면서 자기자신을 파라미터로 넘겨주게 됩니다.

 

자, 이제 body 아래쪽에 자바스크립트를 이용하여 스크립트를 작성해보겠습니다.

<script>
    function toggle(element) {
        console.log(element.checked);
    }
</script>

위 코드는 <head></head> 에 위치해도 되고 <body></body> 사이에 위치해도 됩니다.

당연히 별도 파일로 분리하여 작성해도 됩니다.

분리하여 작성하는 것과 관련해서는 제가 작성한 다른 포스트에서 확인 가능합니다. -> https://keichee.tistory.com/356

저는 <body></body> 사이에 넣어놓았습니다.

<body>
    <label class="switch">
        <input type="checkbox" onclick="toggle(this)">
        <span class="slider round"></span>
    </label>

    <script>
        function toggle(element) {
            console.log(element.checked);
        }
    </script>
</body>

 

자, 여기까지 html 파일 전체 코드가 어떻게 되는지 다시 한번 보여드릴게요.

<!DOCTYPE html>
<html>

<head>
    <link rel="stylesheet" type="text/css" href="toggle.css" />
</head>

<body>
    <label class="switch">
        <input type="checkbox" onclick="toggle(this)">
        <span class="slider round"></span>
    </label>

    <script>
        function toggle(element) {
            console.log(element.checked);
        }
    </script>
</body>

</html>

 

여기까지 완성하여 실행하면 체크박스(토글버튼)을 클릭할 때마다 toggle함수가 실행되면서 현재 체크박스의 상태가 어떻게 바뀌었는지를 출력하게 됩니다.

확인을 위해서 브라우저에서 toggle.html 파일을 새로고침하여 다시 열어주시고,

화면에서 우클릭 > 검사 (inspect)를 선택하여 개발자도구(developer tools)를 열어서 console탭을 열어주세요.

그리고 버튼을 누를때마다 어떤 값이 출력이 되는지 확인해보도록 하겠습니다.

 

토글 버튼 동작 영상

 

자, 이렇게 자바스크립트를 이용해서 토글버튼의 상태값을 출력해보았습니다.

어떤가요? 별로 어렵지 않죠? css 스타일을 해석하기 힘드실 순 있겠으나, 여기서 그런 부분을 자세하게 다루진 않겠습니다.

좀 더 나아가서 토글버튼의 상태값에 따라 ajax 요청을 서버에 날려 실제 DB를 업데이트하거나, 

또는 html의 특정 element를 hide하거나 show하는 등의 기능을 만들어 보세요.

 

그럼 오늘도 즐거운 코딩하시길 바래요 ^-^

 

- 깐깐한 개발자 -

💻 Programming/CSS

[CSS] 포지션(position) 속성 강좌

CSS position 속성 정복하기

 

안녕하세요, 오늘은 자꾸 헷갈리게 만드는 포지션 속성에 대해서 포스팅을 하려합니다.

 

프론트 개발자가 아니다보니 종종 css 를 사용하게 될때마다 제일 헷갈리는게 바로 이 포지션 속성입니다.

 

포지션 속성은 화면상에서 어떤 엘리먼트(요소)의 위치를 어디다가 줄지를 결정할 수 있도록 해주는 속성입니다.

 

즉, 포지셔닝을 할 방법을 지정해주는 속성입니다.

 

화면을 꾸밀 때 html파일에 태그를 써주는데 이때 적힌 순서대로 위에서 아래로 그냥 보여줄 지, 아니면 상위 엘리먼트와 겹쳐서 보여줄 지, 또는 아예 동떨어져서 저~~~~~아래쪽에 위치시킬지도 결정을 할 수 있도록 해줍니다.

 

직접적으로 위치값을 지정해주는 속성은 아니지만 이 속성값에 따라 위치값이 적용이 될지 안될지가 결정되기 때문에 아주 중요한 속성이라고 할 수 있습니다.

 

자, 그럼 이 포지션 속성의 속성값에 어떤 것들이 있는지 먼저 살펴볼까요?

 

포지션 속성의 속성값은 다음 네 가지가 있습니다.

  • static
  • relative
  • fixed
  • absolute

이런 속성을 갖는 엘리먼트들은 부수적으로 top, bottom, left, 그리고 right 속성을 갖게 됩니다.

 

물론 부수적인 값들을 주지 않을 수도 있습니다. 

 

어쨌든 이런 부수적인 위치값들은 position 속성이 없으면 아무런 영향도 미치지 않습니다. 

 

또한 포지션 값에 따라 다르게 동작하기도 합니다.

 

그럼 제일 첫번째 속성부터 한번 살펴보도록 하겠습니다.

 

1. static 

 

static 속성은 궂이 우리가 입력해주지 않아도 기본적으로 적용이 되어있는 속성입니다.

 

예를 들어, 아래 처럼 div 태그에 position 속성을 주지 않았다고 해보죠.

 

<div>이건 static 포지션 속성이 적용된겁니다.</div>

 

아무런 값도 주지 않았지만 저 div 태그에는 position:static 이라는 속성이 기본적으로 주어집니다. 즉,

 

<div style="position:static;">이건 static 포지션 속성이 적용된겁니다.</div>

 

와 동일한 태그가 되는 것이죠.

 

static 속성은 엘리먼트를 위에서부터 아래쪽으로 순서대로 배열시켜주는 속성입니다.

 

네 가지 속성 중에서 유일하게 top, right, bottom, left 속성의 값을 무시하는 속성입니다.

 

 

2. relative

 

 position: relative; 속성을 갖는 엘리먼트들은 원래 기본적인 포지션에서 상대적인 포지션을 가질 수 있도록 해줍니다.

 

위에서 얘기했던 부수적인 옵션들(top, right, bottom, 그리고 left)을 이용해서 원래의 위치에서 상대적인 위치를 지정해줄 수 있습니다. 

 

여기서 말하는 "원래의 위치"라는 것은  position속성에 아무런 값을 주지 않았을 때, 즉, static 일때의 위치를 말합니다. 

 

또한, 다른 컨텐트가 이 엘리먼트에 의해 생긴 빈 공간에 위치할 수는 없습니다.

 

빈공간이란 원래 위치해야할 곳을 의미합니다.

 

relative 속성과 static 속성의 차이는 

static 속성의 경우 top, right, bottom, left 속성으로 위치를 변경할 수 없지만, 

relative는 그것이 가능하다라는 점입니다. 

 

예제를 통해서 static과 relative의 차이를 한번 볼 까요??

 

html파일을 하나 만들어서 아래 코드를 작성해주세요.

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<html>
<head>
<style>
div.static {position: static;border: 3px solid #00f;}
div.relative {position: relative;border: 3px solid #f00;}
</style>
</head>
<body>
 
<div class="static">
This div element has position: static;
</div>
<div class="relative">
This div element has position: relative;
</div>
<div class="static">
This div element has position: static;
</div>
<div class="relative">
This div element has position: relative;
</div>
 
</body>
</html>
cs
 

위 페이지를 열어보면 아래처럼 화면에 출력이 됩니다. 

 

자, 코드를 보면 static 클래스와 relative 클래스 모두 동일한 속성을 갖고있는 것을 알 수 있죠. top, right, bottom, left의 값은 둘 다 없습니다. 이 경우 relative와 static은 아무런 차이가 없습니다. 그저, 태그 순서대로 화면에 출력되죠.

 

이제 static 클래스의 속성에 left:15px 을 한번 줘볼까요?

 

1
2
3
4
<style>
div.static {position: static;border: 3px solid #00f;left: 15px;}
div.relative {position: relative;border: 3px solid #f00;}
</style>
cs

 

결과가 어떻게 나올까요?

 

아무런 차이가 없을 겁니다. static은 top, right, bottom, left 속성값을 무시하기 때문이죠.

 

그럼 이번에는 relative에 left:15px; 속성을 줘 봅시다.

 

 

1
2
3
4
<style>
div.static {position: static;border: 3px solid #00f;}
div.relative {position: relative;border: 3px solid #f00;left: 15px;}
 
</style>
cs

 

 

이번에는 아래 그림처럼 relative 클래스에 해당하는 div 엘리먼트가 움직인 것을 확인할 수 있습니다.

 

 

 

이제 아래처럼 relative클래스에 top:15px; 속성을 추가해 보겠습니다.

 

 

1
2
3
4
<style>
div.static {position: static;border: 3px solid #00f;}
div.relative {position: relative;border: 3px solid #f00;left: 15px;top: 15px;}
 
</style>
cs

 

그럼 어떻게 나올지 상상이 가시나요?

 

결과는 아래처럼 나옵니다.

 

 

 

relative 클래스에 속한 div 엘리먼트들이 아래쪽으로 15px만큼 내려온 것을 확인할 수 있습니다.

 

이제 top속성의 값을 100px로 세팅해보세요. relative 클래스의 div 엘리먼트들이 아래쪽으로 한참 내려가는 것을 확인할 수 있습니다. 여기서 중요한 점은, relative 클래스의 엘리먼트들이 아래로 내려갔다고 해서 static 클래스의 엘리먼트들이 위쪽으로 이동하거나 하지는 않는 다는 것입니다.

 

 

3. fixed

 

fixed 속성은 화면에 보이는 위치가 기준이라고 생각하시면 됩니다. 

 

한번 위치가 결정되면 화면에서 스크롤이 생긴다해도 사라지지 않고 처음 화면에 출력되었던 그자리에 고정적으로 위치합니다. 

 

그래서 속성 이름이 fixed 인겁니다. 

 

이 속성의 경우 relative처럼 top, right, bottom, left 속성으로 위치값을 지정해줄 수 있지만, 

relative 속성과는 달리 원래 있어야 할 위치, 즉, static일 경우에 위치할 곳에 빈공간을 만들지 않습니다.

 

여기서 빈공간을 만든다는 것은 다른 엘리먼트가 그 자리에 위치할 수 없도록 한다는 말과 같습니다.

 

이 속성은 말 그대로 화면을 기준으로 어찌보면 절대적인 위치를 설정하는 것이므로 아마 가장 쉽게 이해할 수 있는 속성이라 생각합니다. 따라서 예제는 생략합니다.

 

 

4. absolute

 

이 속성은 가장 가까운 positioned 조상 엘리먼트에 상대적인 위치를 설정할 수 있도록 해줍니다.

 

fixed 속성이 화면에서 상대적인 위치를 결정할 수 있도록 해주는 속성이라면,

 

absolute는 positioned 조상 엘리먼트에서 상대적인 위치를 결정한다는 점에서 차이가 있습니다.

 

만약, 가장 가까운 positioned 조상 엘리먼트 가 없다면 body를 기준으로 하며 위치값에 따라 스크롤이 생기기도 합니다.

 

여기서, positioned 엘리먼트라는 것은 position 속성 값이 static인 것을 제외하고 position 속성을 갖고있는 엘리먼트를 의미합니다.

 

이 속성은 쇼핑몰 같은 곳에서 사진 위에 왼쪽, 오른쪽 화살표를 오버랩 시키고 해당 화살표를 클릭할 때마다 사진을 바꿔주는 기능을 추가할 때 많이 사용하는 것 같습니다.

 

그게 어떻게 가능하냐구요? 이제부터 저와 함께 살펴보시죠.

 

우선  html 페이지를 하나 만들고 아래처럼 소스를 적어주세요.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE html>
<html>
<head>
<style>
div.relative {width: 360px;height: 200px;border: 3px solid #00f;position: relative;}
div.absolute {width: 200px;height: 100px;border: 3px solid #f00;position: absolute;}
</style>
</head>
<body>
 
<div class="relative">position: relative;
  <div class="absolute">position: absolute;</div>
</div>
 
</body>
</html>
cs

 

위 코드를 보면, relative 클래스의 div 엘리먼트 안에 absolute 클래스의 div 엘리먼트가 존재하고 있습니다.

 

absolute 포지셔닝은 상위에 positioned 엘리먼트가 필요하다는 것을 기억해주세요.

 

여기서 absolute 클래스 div 엘리먼트(12라인)의 positioned 조상 엘리먼트는 relative 클래스 div 엘리먼트(11라인)가 됩니다.

 

위 코드를 화면에 출력해보면 다음과 같습니다.

 

absolute 박스가 relative 박스 안에 있는 모양이죠.

 

이제 absolute에 right:0; 속성을 추가해보도록 하겠습니다.

 

1
2
3
4
<style>
div.relative {width: 360px;height: 200px;border: 3px solid #00f;position: relative;}
 
div.absolute {width: 200px;height: 100px;border: 3px solid #f00;position: absolute;right:0;}
</style>
cs

 

그리고 화면을 새로고침 해보면 ???

 

absolute 박스가 오른쪽으로 붙은 것을 확인할 수 있습니다.

 

 

이제 relative 클래스에 left:150px; 속성을 추가해 보죠.

 

1
2
3
4
<style>
div.relative {width:360px;height:200px;border:3px solid #00f;position:relative;left:150px;}
 
div.absolute {width:200px;height:100px;border:3px solid #f00;position:absolute;right:0;}
</style>
cs

 

어떤 모양이 나올까요? absolute 박스는 relative 박스 안에 있는데 relative 박스를 우측으로 움직였습니다.

 

relative 박스의 좌측에 150px만큼 공간을 추가했고, 그 안에있는 absolute 박스는 relative 박스 오른쪽에 꼭 붙어있는 것을 확인할 수 있습니다.

 

즉, absolute 박스는 relative 박스에 상대적인 위치에 고정된다는 것을 알 수 있죠.

 

이 속성을 응용하면 relative 박스에 이미지가 로딩 되도록 하고, absolute 박스에 화살표 이미지가 로딩되도록 해서 두 개의 이미지를 오버래핑 시킬 수도 있습니다.

 

이건 직접 한번 해보세요 ~~

 

 

 

 

자, 어떤가요? 이제 CSS를 이용한 포지셔닝을 마음대로 할 수 있을 것 같나요?

 

그렇다면 다행이네요~ ^-^ 제가 설명을 잘 해드린 것이니까요 ㅎㅎㅎ

 

이만 오늘의 포스팅을 마치겠습니다.

 

궁금한 점이 있으시면 댓글남겨주세요 아는 한 열심히 답변드리겠습니다 ^-^

 

 

💻 Programming/CSS

[CSS] 27. Layouts ( 레이아웃 )

웹페이지를 디자인하다보면 구역을 나눠서 정보를 표시하게 됩니다.

CSS에서는 이렇게 구역을 나눈것처럼 보여지도록 할 수 있습니다. 실제로 테이블이나 frame으로 나눈것은 아니고 그냥 그렇게 보이게끔 하는 거죠.


CSS also provides table-layout property to make your tables load much faster.Following is the example:

<table style="table-layout:fixed;width:600px;">
  <tr height="30">
    <td width="150">CSS table layout cell 1</td>
    <td width="200">CSS table layout cell 2</td>
    <td width="250">CSS table layout cell 3</td>
  </tr>
</table>

You will notice the benefits more on large tables. The reason this makes tables load faster is because with traditional HTML, the browser had to calculate every cell before finally rendering the table. When you set the table-layout algorithm to fixed however, it only needs to look at the first row before rendering the whole table. This means that your table will need to have fixed column widths and row heights.

Sample Column Layout:

CSS를 이용해서 간단한 Column Layout 을 만들어보겠습니다.

우선 문서 전체의 마진과 패딩, 백그라운드를 설정합니다.

<style tyle="text/css">
<!--
body {
    margin:9px 9px 0 9px;
    padding:0;
    background:#FFF;
}
-->
</style>


Now we will define a column with yellow color and later we will attach this rule to a <div>:

<style tyle="text/css">
<!--
#level0 {
     background:#FC0;
}
-->
</style>


Up to this point we will have a document with yellow body, so lets now define another division inside level0:

<style tyle="text/css">
<!--
#level1 {
    margin-left:143px;
    padding-left:9px;
    background:#FFF;
}
-->
</style>


Now we will nest one more division inside level1 and we will change just background color:

<style tyle="text/css">
<!--
#level2 {
    background:#FFF3AC;
}
-->
</style>


Finally we use the same technique, nest a level3 division inside level2 to get the visual layout for the right column:

<style tyle="text/css">
<!--
#level3 {
    margin-right:143px;
    padding-right:9px;
    background:#FFF;
}
#main {
    background:#CCC;
}
-->
</style>


위 소스들을 모두 합쳐서 하나로 만들어보죠

<style tyle="text/css">
<!--
body {
    margin:9px 9px 0 9px;
    padding:0;
    background:#FFF;}
  #level0 {
    background:#FC0;}
  #level1 {
    margin-left:143px;
    padding-left:9px;
    background:#FFF;}
  #level2 {
    background:#FFF3AC;}
  #level3 {
    margin-right:143px;
    padding-right:9px;
    background:#FFF;}
  #main {
    background:#CCC;}
-->
</style>
<body>
  <div id="level0">
    <div id="level1">
      <div id="level2">
        <div id="level3">
          <div id="main">
            Final Content goes here...
          </div>
        </div>
      </div>
    </div>
  </div>
</body>


자, 이제 이걸 테스트 해보세요. ^____^








Reference : http://www.tutorialspoint.com/css/css_layouts.htm





자~ 오늘은 CSS 필터에 대해서 알아볼 텐데요~ 순수한 CSS를 이용해서 텍스트나 이미지 등등에 효과를 주는 방법을 알아볼 것입니다.

이 필터는 IE 4.0 이상에서만 작동합니다. 

( 테스트를 해봤는데 이 CSS 필터는 최근 브라우저( Chrome, IE, FireFox )에서는 지원을 안하는 것 같네요..^^;; 그냥 이런 것도 있구나 하시면 될것 같습니다.)


자, 그럼 CSS 필터에 대해서 하나하나 알아보도록 할까요?


모든 예제는 브라우저 별로 결과가 다르게 보일 수 있다는 것을 명심하세요. 적용이 안되는 브라우저도 있습니다.


Alpha Channel

이건 뭐 이미 다 아시리라 생각합니다. 알파 값이죠. 객체의 투명도를 설정하는 필터입니다.

다음은 이 필터에서 사용할 수 있는 파라미터와 그에대한 설명입니다.

ParameterDescription
opacityLevel of the opacity. 0 is fully transparent, 100 is fully opaque.
finishopacityLevel of the opacity at the other end of the object.
styleThe shape of the opacity gradient.

0 = uniform
1 = linear
2 = radial
3 = rectangular
startXX coordinate for opacity gradient to begin.
startYY coordinate for opacity gradient to begin.
finishXX coordinate for opacity gradient to end.
finishYY coordinate for opacity gradient to end.

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Alpha(Opacity=100, FinishOpacity=0, Style=2, StartX=20, StartY=40, FinishX=0, FinishY=0)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: blue; Filter: Alpha(Opacity=100, FinishOpacity=0, Style=1, StartX=0, StartY=0, FinishX=580, FinishY=0)">CSS Tutorials</div>




Motion Blur

This will be used to create blurred pictures or text with the direction and strength. Following are the parameters which can be used in this filter:

ParameterDescription
addTrue or false. If true the image is added to the blurred image and if false the image is not added to the blurred image.
directionThe direction of the blur, going clockwise, rounded to 45-degree increments. The default value is 270 (left).

0 = Top
45 = Top right
90 = Right
135 = Bottom right
180 = Bottom
225 = Bottom left
270 = Left
315 = Top left
strengthThe number of pixels the blur will extend. The default is 5 pixels.

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Blur(Add = 0, Direction = 225, Strength = 10)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: blue; Filter: Blur(Add = 1, Direction = 225, Strength = 10)">CSS Tutorials</div>


Chroma Filter

This will be used to make any particular color transparent and usually it is used with images. You can use it with scrollbars also.Following are the parameters which can be used in this filter:

ParameterDescription
color The color that you'd like to be transparent.

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Chroma(Color = #FFFFFF)">

<p>Text Example:</p>
<div style="width: 580; height: 50; font-size: 30pt; font-family: Arial Black; color: #3300FF; Filter: Chroma(Color = #3300FF)">CSS Tutorials</div>




Drop Shadow Effect

This will be used to create a shadow of your object at the specified X (horizontal) and Y (vertical) offset and color. . Following are the parameters which can be used in this filter:

ParameterDescription
color The color, in #RRGGBB format, of the dropshadow.
offX Number of pixels the drop shadow is offset from the visual object, along the x-axis. Positive integers move the drop shadow to the right, negative integers move the drop shadow to the left.
offY Number of pixels the drop shadow is offset from the visual object, along the y-axis. Positive integers move the drop shadow down, negative integers move the drop shadow up.
positiveIf true, all opaque pixels of the object have a dropshadow. If false, all transparent pixels have a dropshadow. The default is true.

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Chroma(Color = #000000) DropShadow(Color=#FF0000, OffX=2, OffY=2, Positive=1)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: DropShadow(Color=#000000, OffX=2, OffY=2, Positive=1)">CSS Tutorials</div>




Flip Effect

This will be used to create a mirror image of the object. Following are the parameters which can be used in this filter:

ParameterDescription
FlipH Creates a horizontal mirror image
FlipV Creates a vertical mirror image

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: FlipH">

<img src="/images/css.gif" alt="CSS Logo" style="Filter: FlipV">

<p>Text Example:</p>
<div style="width: 300; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: FlipV">CSS Tutorials</div>




Glow Effect

This will be used to create a glow around the object. If it is a transparent image then glow is created around the opaque pixels of it. Following are the parameters which can be used in this filter:

ParameterDescription
color The color you want the glow to be.
strengthThe intensity of the glow (from 1 to 255).

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Chroma(Color = #000000) Glow(Color=#00FF00, Strength=20)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Glow(Color=#00FF00, Strength=20)">CSS Tutorials</div>




Grayscale Effect

This will be used to convert the colors of the object to 256 shades of gray. Following are the parameters which can be used in this filter:

ParameterDescription
gray Converts the colors of the object to 256 shades of gray.

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Gray">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Gray">CSS Tutorials</div>




Invert Effect

This will be used to map the colors of the object to their opposite value in the color spectrum ie. to create a negative image. Following are the parameters which can be used in this filter:

ParameterDescription
InvertMaps the colors of the object to their opposite value in the color spectrum.

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: invert">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: invert">CSS Tutorials</div>


Mask Effect

This will be used to turn transparent pixels to a specified color and makes opaque pixels transparent. Following are the parameters which can be used in this filter:

ParameterDescription
color The color that the transparent areas will become.

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="FILTER: Chroma(Color = #000000) Mask(Color=#00FF00)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Mask(Color=#00FF00)">CSS Tutorials</div>




Shadow Filter

This will be used to create an attenuated shadow in the direction and color specified. This is a filter lies in between Dropshadow and a Glow. Following are the parameters which can be used in this filter:

ParameterDescription
color The color that you want the shadow to be.
directionThe direction of the blur, going clockwise, rounded to 45-degree increments. The default value is 270 (left).

0 = Top
45 = Top right
90 = Right
135 = Bottom right
180 = Bottom
225 = Bottom left
270 = Left
315 = Top left

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="FILTER: Chroma(Color = #000000) Shadow(Color=#00FF00, Direction=225)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Shadow(Color=#0000FF, Direction=225)">CSS Tutorials</div>




Wave Effect

This will be used to gives the object a sine wave distortion to make it look wavey. Following are the parameters which can be used in this filter:

ParameterDescription
addA value of 1 adds the original image to the waved image, 0 does not.
freq The number of waves.
lightThe strength of the light on the wave (from 0 to 100).
phase At what degree the sine wave should start (from 0 to 100).
strength The intensity of the wave effect.

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="FILTER: Chroma(Color = #000000) Wave(Add=0, Freq=1, LightStrength=10, Phase=220, Strength=10)">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; Filter: Wave(Add=0, Freq=1, LightStrength=10, Phase=20, Strength=20)">CSS Tutorials</div>




X-Ray Effect

This will be used to grayscales and flattens the color depth. Following are the parameters which can be used in this filter:

ParameterDescription
xrayGrayscales and flattens the color depth.

예제:

<p>Image Example:</p>
<img src="/images/css.gif" alt="CSS Logo" style="Filter: Xray"">

<p>Text Example:</p>
<div style="width: 357; height: 50; font-size: 30pt; font-family: Arial Black; color: red; style="Filter: Xray">CSS Tutorials</div>






Reference : http://www.tutorialspoint.com/css/css_text_effects.htm 





💻 Programming/CSS

[CSS] 25. @ Rules ( @ 규칙들 )

이번 포스팅에서는 @ 규칙에 대해서 알아보도록 하겠습니다.

문서에 다른 CSS파일을 import할 때 @import를 쓰게 됩니다.  

이런 규칙들이 몇가지 있는데 이번에는 다음 네가지에 대해서만 알아보도록 하겠습니다. 

 

  • @import 외부 CSS파일을 현재 CSS파일에 import합니다.

  • @charset CSS파일의 캐릭터셋을 지정합니다.

  • @font-face 문서에서의 문서체를 지정합니다.

  • !important 다른 스타일을 오버라이드 합니다.

NOTE: 위 네가지 이외에도 다른 규칙들도 있지만 여기서는 다루지 않습니다. 


The @import rule

이 규칙은 아래 두가지 방법중 한가지 방법으로 사용하시면 됩니다.

로컬파일을 import하는 방법과 url을 이용하여 원격파일을 import하는 방법이 있습니다. 

<style tyle="text/css">
<!--
@import "mystyle.css";
or
@import url("mystyle.css");
.......other CSS rules .....
-->
</style>

CSS를 모듈화 할 수 있게끔 해주는 규칙이므로 중요한 규칙이고 자주 사용하시게 될겁니다. 


The @charset Rule

캐릭터셋을 정의하는 규칙이죠. 별거 없습니다.

<style tyle="text/css">
<!--
@charset "iso-8859-1"
.......other CSS rules .....
-->
</style>


The @font-face Rule

문서내에서 사용될 문서체를 정의하는 규칙입니다. 또한 다운로드할 폰트의 위치를 지정해주기 위한 규칙이기도 합니다.

일반적으로 @font-face 규칙은 매우 복잡하고 폰트 전문가가 아닌 이상 사용을 권장하지도 않습니다.

 

다음 예제를 보시죠. 

<style tyle="text/css">
<!--
@font-face {
  font-family: "Scarborough Light";
 src: url("http://www.font.site/s/scarbo-lt");
}
@font-face {
 font-family: Santiago;
 src: local ("Santiago"),
 url("http://www.font.site/s/santiago.tt")
 format("truetype");
 unicode-range: U+??,U+100-220;
 font-size: all;
 font-family: sans-serif;
}
-->
</style>


The !important Rule

CSS가 브라우저에 적용될 때 순서대로 적용이 되도록 되어있습니다. 따라서 앞에서 정의했던 것이 적용이 된 뒤에 마지막에 정의한 것이 적용이 되는데 이때 동일한 요소에 대해서 다른 값을 정의해버리면 마지막에 정의한 값이 적용되고 앞에서 정의한 값은 적용이 되지 않습니다. 

만약 어떤 속성이 정말 중요해서 이건 실수로 오버라이드 되면 안된다 싶을때 사용하는것이 바로 이 !important 규칙입니다.  

이 규칙을 적용한 스타일은 문서의 어느곳에나 있어도 적용이 됩니다. 

 

다음 예제를 한번 보시죠.

<style tyle="text/css">
<!--
p { color: #ff0000; }
p { color: #000000; }
-->
</style>

동일한 요소에 서로다른 색상을 적용시키는 스타일이 선언되어있습니다. 앞에꺼는 빨간색, 뒤에꺼는 검은색이죠. 그러면 후자인 검정색만 적용이 됩니다. 이때 빨간색 속성이 중요한 속성이다라고 아래처럼 선언을 해주시면....

<style tyle="text/css">
<!--
p { color: #ff0000 !important; }
p { color: #000000; }
-->
</style>

뒤에 검은색 속성을 정의했다고 하더라도 빨간색이 적용되어지게 됩니다.

 

 

 

 

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_at_rules.htm 

 

 

 

 

💻 Programming/CSS

[CSS] 24. Pseudo Elements ( 슈도 엘리먼트 )

 

이번 포스팅에서는 슈도 엘리먼트들에 대해서 알아보도록 하겠습니다.

 

이녀석들은 슈도 클래스와 비슷한 녀석들입니다.  

 

이름 말고는 다른게 없어보이네요. ( 사실 저도 잘 몰라서 ...ㅋㅋㅋ )

 

문법도 슈도 클래스와 동일해보입니다.

selector:pseudo-element {property: value}

 

CSS 클래스와 함께 쓰이기도 하죠.

selector.class:pseudo-element {property: value}

 

가장 많이 사용되는 pseudo-elements에는 다음과 같은 것들이 있습니다. 

ValueDescription
:first-lineUse this element to add special styles to the first line of the text in a selector.
:first-letterUse this element to add special style to the first letter of the text in a selector.
:beforeUse this element to insert some content before an element.
:after Use this element to insert some content after an element.


The :first-line pseudo-element

Following is the example which demonstrates how to use :first-line element to add special effect to the first line of elements in the document .

<style type="text/css">
p:first-line { text-decoration: underline; }
p.noline:first-line { text-decoration: none; }
</style>
<p class="noline"> This line would not have any underline
because this belongs to nline class.</p>

<p>The first line of this paragraph will be underlined
as defined in the CSS rule above. Rest of the lines in this
paragraph will remain normal. This example shows how to use
:first-line pseduo element to give effect to the first line
of any HTML element.</p>

 

결과는 아래와 같습니다.



The :first-letter pseudo-element

Following is the example which demonstrates how to use :first-letter element to add special effect to the first letter of elements in the document .

<style type="text/css">
p:first-letter { font-size: 3em; text-color:red; }
p.normal:first-letter { font-size: 10px; }
</style>
<p class="normal"> First character of this paragraph will 
be normal and will have font size 10 px;</p>

<p>The first character of this paragraph will be 3em big
and in red color as defined in the CSS rule above. Rest of the
characters in this paragraph will remain normal. This example 
shows how to use :first-letter pseduo element to give effect to
the first characters  of any HTML element.</p>

 

결과는 아래와 같습니다.




The :before pseudo-element

Following is the example which demonstrates how to use :before element to add some content before any element .

<style type="text/css">
p:before
{
content: url(/images/bullet.gif)
}
</style>
<p> This line will be preceded by a bullet.</p>
<p> This line will be preceded by a bullet.</p>
<p> This line will be preceded by a bullet.</p>

 

결과는 아래와 같습니다.

 

 


The :after pseudo-element

Following is the example which demonstrates how to use :after element to add some content after any element .

<style type="text/css">
p:after
{
content: url(/images/bullet.gif)
}
</style>
<p> This line will be succeeded by a bullet.</p>
<p> This line will be succeeded by a bullet.</p>
<p> This line will be succeeded by a bullet.</p>

 

 

 

결과는 아래와 같습니다.

 

 

 

 

 

 

손수 페이지 만들어서 직접 테스트 해보는 것 잊지 마세요.!!!! ^-^ 

 

 

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_pseudo_elements.htm

 

 

 

 

 

 

 

💻 Programming/CSS

[CSS] 23. Pseudo Classes ( 슈도 클래스 )

<<" ">>" "<" ">"; } </style>

이번에는 CSS의 슈도클래스에 대해서 알아보도록 하겠습니다.  

슈도클래스는 특정 셀렉터에 특별한 효과를 부여하기 위해서 사용됩니다. Javascript 나 어떠한 다른 script 를 사용할 필요가 없습니다.

 

슈도클래스를 사용하는 기본적인 문법은 다음과 같습니다. 

selector:pseudo-class {property: value}

 

CSS 클래스를 사용할 수도 있습니다. 

selector.class:pseudo-class {property: value}

 

다음은 가장 많이 사용되는 슈도 클래스들 목록 및 설명입니다.

ValueDescription
:linkUse this class to add special style to an unvisited link.
:visitedUse this class to add special style to a visited link.
:hoverUse this class to add special style to an element when you mouse over it.
:active Use this class to add special style to an active element.
:focusUse this class to add special style to an element while the element has focus.
:first-childUse this class to add special style to an element that is the first child of some other element.
:langUse this class to specify a language to use in a specified element.

<style>...</style> 블락 내에 슈도 클래스를 이용하게 될 때에는 다음과 같은 사항을 주의해야합니다. 

  • a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective.

  • a:active MUST come after a:hover in the CSS definition in order to be effective.

  • Pseudo-class names are not case-sensitive.

  • Pseudo-class are different from CSS classes but they can be combined.


The :link pseudo-class

다음은 단순히 링크의 색상을 변경하는 예제입니다. 

<style type="text/css">
a:link {color:#000000}
</style>
<a href="/html/index.htm">Black Link</a>


The :visited pseudo-class

다음은 한번 이상 방문한 링크의 색상을 변경하는 예제입니다. 

<style type="text/css">
a:visited {color: #006600}
</style>
<a href="/html/index.htm">Click this link</a>

 

 

 

 

 

The :hover pseudo-class

다음은 마우스 커서가 링크 위에 올라갔을 때 색깔을 변경하도록 하는 예제입니다.

<style type="text/css">
a:hover {color: #FFCC00}
</style>
<a href="/html/index.htm">Bring Mouse Here</a>



The :active pseudo-class

 :active 슈도 클래스는 활성화된 요소에 대한 속성을 지정합니다.  

다음은 활성화된 링크의 색상을 변경하는 예제입니다. 

<style type="text/css">
a:active {color: #FF00CC}
</style>
<a href="/html/index.htm">Click This Link</a>



The :focus pseudo-class

이 클래스는 포커스를 받은 요소에 대한 속성의 속성값을 지정할 때 사용합니다. 

다음은 포커스된 링크의 색상을 변경하는 예제입니다. 

<style type="text/css">
a:focus {color: #0000FF}
</style>
<a href="/html/index.htm">Click this Link</a>

 

 

 


The :first-child pseudo-class

 :first-child 슈도 클래스는 이름만 봐도 첫번째 자식에 대한 속성을 설정하는거라고 보이네요.

이 슈도클래스를 사용하시려면 IE 에서는 문서 가장 윗부분에 <!DOCTYPE> 를 넣어주셔야 합니다.

 

그럼 예제를 한번 보시죠. 모든 div태그의 첫번째 문단을 인덴트하여 화면에 뿌려주는 예제입니다. 

<style type="text/css">
div > p:first-child
{
text-indent: 25px;
}
</style>
<div>
<p>
First paragraph in div. This paragraph will be indented
</p>
<p>
Second paragraph in div. This paragraph will not be  indented
</p>
</div>

But it will not match the paragraph in this HTML:

<div>
<h3>Heading</h3>
<p>
The first paragraph inside the div.
This paragraph will not be effected.
</p>
</div>

 

결과는 아래와 같습니다. 

       First paragraph in div. This paragraph will be indented

Second paragraph in div. This paragraph will not be indented

But it will not match the paragraph in this HTML:

Heading

The first paragraph inside the div.
This paragraph will not be effected.

 


The :lang pseudo-class

 :lang 슈도 클래스는 특정 요소의 lang속성에 따라서 다른 값을 줄 때 사용합니다.

다국어 처리를 필요로하는 웹페이지를 만들때 유용하게 사용하실 수 있습니다. 예를 들면 인용문구 같은 경우에 불어에서는 꺽쇠 두개로 인용문구를 표현하지만 영어에서는 그냥 홑따옴표나 쌍따옴표를 이용합니다. 이럴때 이 :lang 슈도 클래스를 이용하시면 좋습니다.

그럼 예제를 통해서 좀더 알아보도록 하죠.  

 

다음 예제는 <blockquote> 태그를 현재 사용중인 언어에 맞게 변경해줍니다.

<style type="text/css">
/* Two levels of quotes for two languages*/
:lang(en) { quotes: '"' '"'  "'"  "'"; }
:lang(fr) { quotes: "<<" ">>" "<" ">"; }
</style>
<p>...<q lang="fr">A quote in a paragraph</q>...</p>

위 예제에서 :lang 셀렉터는 문서 전체 요소에 적용됩니다.   

 

결과는 아래와 같습니다. 

 

...<<A quote in a paragraph>>...

 

 

 

 

 


 

 

Reference : http://www.tutorialspoint.com/css/css_pseudo_classes.htm

 

 

 

 

 


💻 Programming/CSS

[CSS] 22. Layers ( 레이어 )

이번 포스팅에서는 레이어 관련 CSS속성에 대해서 알아보도록 하겠습니다.

 

중학교 때 집합을 배우게 되면 동그라미 두개를 겹쳐서 그리는 것 부터 시작하죠?

그런것이 바로 레이어링 하는 것입니다.

 

레이어링을 위한 속성에는 z-index라는 것이 있습니다.

다음 예제를 한번 볼까요??

 

<div style="background-color:red;
 width:300px;
 height:100px;
 position:relative;
 top:10px;
 left:80px;
 z-index:2">
</div>
<div style="background-color:yellow;
 width:300px;
 height:100px;
 position:relative;
 top:-60px;
 left:35px;
 z-index:1;">
</div>
<div style="background-color:green;
width:300px;
 height:100px;
 position:relative;
 top:-220px;
 left:120px;
 z-index:3;">
</div>

 

결과는 아래처럼 나올 것입니다. 




어떤가요??? 간단하죠???


 

 

 

 

 

 

Reference :  http://www.tutorialspoint.com/css/css_layers.htm

 

 

 

 

 

💻 Programming/CSS

[CSS] 21. Positioning ( 포지셔닝, 위치 )

이번 포스팅에서는 CSS를 이용한 위치 설정에 대해서 알아보도록 하겠습니다.

 

우선 CSS에서 제공하는 위치 관련 속성은 position이 있습니다.

 

그리고 위치는 크게 절대위치와 상대위치가 있습니다.

 

그럼 하나씩 알아보도록 할까요? 


Relative Positioning:

상대 위치 설정에서 사용되는 하위 속성으로는 top, bottom, left와 right가 있습니다.  

top과 left의 속성값이 마이너스 (- ) 숫자를 사용함으로서 bottom과 right를 표현할 수 있습니다. 

  • Move Left - Use a negative value for left.
  • Move Right - Use a positive value for left.
  • Move Up - Use a negative value for top.
  • Move Down - Use a positive value for top.

NOTE: You can use bottom or right values as well in the same way as top and left.

 

다음 예제를 보시죠.

<div style="position:relative;left:80px;top:2px;
            background-color:yellow;">
This div has relative positioning.
</div>

This will produce following result:

This div has relative positioning.

 


Absolute Positioning:

절대 포지셔닝은 특정 위치에 항상 위치할 수 있도록 고정시키는 것이죠.

상대 포지셔닝처럼 top, left, bottom, right 모두 사용가능합니다. 사용방법도 동일하죠.

  • Move Left - Use a negative value for left.
  • Move Right - Use a positive value for left.
  • Move Up - Use a negative value for top.
  • Move Down - Use a positive value for top.

NOTE: You can use bottom or right values as well in the same way as top and left.

 

다음 예제를 보시죠.

<div style="position:absolute;left:80px;top:20px;
            background-color:yellow;">
This div has absolute positioning.
</div>

 

결과는 직접 테스트해보시고 보도록 하세요. ^_^ 


Fixed Positioning:

고정 포지셔닝은 자칫 잘못 이해하면 절대 포지셔닝과 동일하다고 생각하실 수 있는데 이 고정 포지셔닝은 상대 + 절대 포지셔닝이라고 생각하시면 됩니다. 고정 포지셔닝은 눈으로 보여지는 화면의 특정 위치에 고정시키는 것입니다. 스크롤링이 있더라도 무조건 화면의 특정위치에 보이도록 하는 속성이죠.

역시 상대, 절대 포지셔닝처럼 top, left, bottom, right 속성을 사용할 수 있으며 사용방법도 동일합니다. 

  • Move Left - Use a negative value for left.
  • Move Right - Use a positive value for left.
  • Move Up - Use a negative value for top.
  • Move Down - Use a positive value for top.

NOTE: You can use bottom or right values as well in the same way as top and left.

 

다음 예제를 보시죠. 

<div style="position:fixed;left:80px;top:20px;
            background-color:yellow;">
This div has fixed positioning.
</div>

 

결과는 직접 테스트해보시고 보도록 하세요. ^_^

 

 

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_positioning.htm 

 

 

 

 

💻 Programming/CSS

[CSS] 20. Visibility ( 가시성 )

이번에는 CSS를 이용해서 특정 요소를 화면에서 안보이도록 설정하는 것을 해보겠습니다.  

화면을 구성하다보면 화면에 그리기는 그려야 하는데 사용자에게 보여주면 안되는 것들이 있을 수도 있겠죠?

 

visibility 속성이 바로 그것을 위한 속성입니다. 사용자가 원할 때만 보여주면 되는 그런 요소들을 위해서 사용하시면 되는 속성입니다.


NOTE: 중요한 정보들을 단순히 안보이게끔 하는데는 사용하시면 안됩니다. 화면에 정보가 뿌려는 지지만 사람 눈에만 안보이도록 속여놓은 것이기 때문에 언제든지 사용자가 볼 수 있다는 것을 명심하세요.

 

이 속성은 다음과 같은 속성값들을 가질 수 있습니다.

ValueDescription
visibleThe box and its contents are shown to the user.
hiddenThe box and its content are made invisible, although they still affect the layout of the page.
collapseThis is for use only with dynamic table columns and row effects.

 

다음 예제를 한번 보시죠. 

<p>
This paragraph should be visible in normal way.
</p>
<p style="visibility:hidden;">
This paragraph should not be visible.
</p>

 

결과는 아래와 같습니다. 

This paragraph should be visible in normal way.

 

 

 

두개의 문단을 출력하는데 두번째 문단은 visibility속성값이 hidden이라서 눈에 보이지는 않겠지만 저기 위에 분명 있습니다.

 

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_visibility.htm 

 

 

 

 

💻 Programming/CSS

[CSS] 19. Scrollbars ( 스크롤바 )

이번 포스팅에서는 CSS를 이용해서 스크롤바를 설정하는 방법에 대해서 알아보도록 하겠습니다.

 

CSS 속성 중에 overflow 라는 속성이 있는데 이녀석은 컨텐트 박스보다 많은 양의 컨텐트가 들어갈 경우에 컨텐트가 어떻게 보여져야 하는지에 대해서 설정해주는 속성입니다.

 

이 속성에 대한 속성값은 다음과 같은 값들이 있습니다. 

ValueDescription
visibleAllows the content to overflow the borders of its containing element.
hiddenThe content of the nested element is simply cut off at the border of the containing element and no scrollbars is visible.
scrollThe size of the containing element does not change, but the scrollbars are added to allow the user to scroll to see the content.
autoThe purpose is the same as scroll, but the scrollbar will be shown only if the content does overflow.

 

다음 예제를 보실까요. 

<style type="text/css">
.scroll{
 display:block;
 border: 1px solid red;
 padding:5px;
 margin-top:5px;
 width:300px;
 height:50px;
 overflow:scroll;
 }
.auto{
 display:block;
 border: 1px solid red;
 padding:5px;
 margin-top:5px;
 width:300px;
 height:50px;
 overflow:auto;
 }
</style>
<p>Example of scroll value:</p>
<div class="scroll">
I am going to keep lot of content here just to show
you how scrollbars works if there is an overflow in
an element box. This provides your horizontal as well
 as vertical scrollbars.
</div>
<br />
<p>Example of auto value:</p>
<div class="auto">
I am going to keep lot of content here just to show
you how scrollbars works if there is an overflow in
an element box. This provides your horizontal as well
as vertical scrollbars.
</div>

 

결과는 아래와 같습니다. ( 결과 이미지 )

 

 

 직접 페이지를 만들어서 구현해보세요. ^-^ 

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_scrollbars.htm  

 

 

 

 

💻 Programming/CSS

[CSS] 18. Dimension ( 높이, 너비, width, height )

이번에는 dimension에 대해서 포스팅을 해보도록 하겠습니다. 여기서 말하는 디멘션이란 3차원 4차원 이런 것을 말하는 것이 아니고 음...단지 너비와 높이를 다루는 것을 말합니다.  

컨텐트가 들어가는 박스의 디멘션과 관련된 속성들에는 다음과 같은 것들이 있습니다.

  •  height 박스의 높이를 결정짓는 속성입니다.

  •  width 박스의 너비를 지정하는 속성이죠.

  •  line-height 글자 라인의 높이를 지정합니다.

  •  max-height 박스의 최대 높이를 제한합니다.

  •  min-height 박스의 최소 높이를 제한합니다.

  •  max-width 박스의 최대 너비를 제한.

  •  min-width 박스의 최소 너비를 제한.


The height and width Properties:

The height and width properties allow you to set the height and width for boxes. They can take values of a length, a percentage, or the keyword auto.

 

다음 예제를 보시죠. 

<p style="width:400px; height:100px;border:1px solid red;
             padding:5px; margin:10px;">
This paragraph is 400pixels wide and 100 pixels high
</p>

 

결과는 아래와 같습니다.

This paragraph is 400pixels wide and 100 pixels high

 


The line-height Property:

The line-height property allows you to increase the space between lines of text. The value of the line-height property can be a number, a length, or a percentage.

 

다음 예제를 보시죠.

<p style="width:400px; height:100px;border:1px solid red;
             padding:5px; margin:10px;line-height:30px;">
This paragraph is 400pixels wide and 100 pixels high
and here line height is 30pixels.This paragraph is 400 pixels
wide and 100 pixels high and here line height is 30pixels.
</p>

 

결과는 아래와 같습니다.

This paragraph is 400pixels wide and 100 pixels high and here line height is 30pixels.This paragraph is 400 pixels wide and 100 pixels high and here line height is 30pixels.

 


The max-height Property:

The max-height property allows you to specify maximum height of a box. The value of the max-height property can be a number, a length, or a percentage.

NOTE: This property does not work in either Netscape 7 or IE 6.

 

다음 예제를 보시죠.

<p style="width:400px; max-height:10px;border:1px solid red;
             padding:5px; margin:10px;">
This paragraph is 400px wide and max height is 10px
This paragraph is 400px wide and max height is 10px
This paragraph is 400px wide and max height is 10px
This paragraph is 400px wide and max height is 10px
</p>
<img alt="logo" src="/images/css.gif" width="95" height="84" />

 

결과는 아래와 같습니다.

This paragraph is 400px wide and max height is 10px This paragraph is 400px wide and max height is 10px This paragraph is 400px wide and max height is 10px This paragraph is 400px wide and max height is 10px

logo

 


The min-height Property:

The min-height property allows you to specify minimum height of a box. The value of the min-height property can be a number, a length, or a percentage.

NOTE: This property does not work in either Netscape 7 or IE 6.

 

다음 예제를 보시죠.

<p style="width:400px; min-height:200px;border:1px solid red;
             padding:5px; margin:10px;">
This paragraph is 400px wide and min height is 200px
This paragraph is 400px wide and min height is 200px
This paragraph is 400px wide and min height is 200px
This paragraph is 400px wide and min height is 200px
</p>
<img alt="logo" src="/images/css.gif" width="95" height="84" />

 

결과는 아래와 같습니다.

This paragraph is 400px wide and min height is 200px This paragraph is 400px wide and min height is 200px This paragraph is 400px wide and min height is 200px This paragraph is 400px wide and min height is 200px

logo

 


The max-width Property:

The max-width property allows you to specify maximum width of a box. The value of the max-width property can be a number, a length, or a percentage.

NOTE: This property does not work in either Netscape 7 or IE 6.

 

다음 예제를 보시죠.

<p style="max-width:100px; height:200px;border:1px solid red;
             padding:5px; margin:10px;">
This paragraph is 200px high and max width is 100px
This paragraph is 200px high and max width is 100px
This paragraph is 200px high and max width is 100px
This paragraph is 200px high and max width is 100px
This paragraph is 200px high and max width is 100px
</p>
<img alt="logo" src="/images/css.gif" width="95" height="84" />

 

결과는 아래와 같습니다.

This paragraph is 200px high and max width is 100px This paragraph is 200px high and max width is 100px This paragraph is 200px high and max width is 100px This paragraph is 200px high and max width is 100px This paragraph is 200px high and max width is 100px

logo

 


The min-width Property:

The min-width property allows you to specify minimum width of a box. The value of the min-width property can be a number, a length, or a percentage.

NOTE: This property does not work in either Netscape 7 or IE 6.

 

다음 예제를 보시죠.

<p style="min-width:400px; height:100px;border:1px solid red;
             padding:5px; margin:10px;">
This paragraph is 100px high and min width is 400px
This paragraph is 100px high and min width is 400px
This paragraph is 100px high and min width is 400px
This paragraph is 100px high and min width is 400px
This paragraph is 100px high and min width is 400px
</p>
<img alt="logo" src="/images/css.gif" width="95" height="84" />

 

결과는 아래와 같습니다. 

This paragraph is 100px high and min width is 400px This paragraph is 100px high and min width is 400px This paragraph is 100px high and min width is 400px This paragraph is 100px high and min width is 400px This paragraph is 100px high and min width is 400px

logo

 

 

 

 

꼭 따라해 보시는 것 잊지 마시고, 이것저것 수치도 바꿔서 해보세요. ^-^  

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_dimension.htm 

 

 

 

 

💻 Programming/CSS

[CSS] 17. Outlines ( 외곽선, 아웃라인 )

이번에는 외곽선 속성에 대해서 알아보도록 하겠습니다.

 

아웃라인(외곽선)은 테두리와 많이 유사합니다. 그래서 준비했습니다. 

 

이 두개의 차이점:

  • 외곽선은 공간을 차지하지 않습니다.

  • 외곽선은 직사각형일 필요가 없습니다.

  • 외곽선은 사방이 모두 똑같은 선입니다. 테두리처럼 왼쪽은 점선, 오른쪽은 직선, 이렇게 따로 설정할 수가 없습니다.

NOTE: 이 속성도 IE 6 이나 Netscape 7에서는 안된다고 하는군요. 아직도 이런 브라우저를 사용하시는 분들은 없겠지만요 ㅋ 

 

자 그럼 외곽선 관련 속성에 어떤것들이 있는지 한번 알아봅시다. 

  •  outline-width

  •  outline-style  

  •  outline-color  

  •  outline  


The outline-width Property:

The outline-width property specifies the width of the outline to be added to the box. Its value should be a length or one of the values thin, medium, or thick . just like the border-width attribute

A width of zero pixels means no outline.

 

다음 예제를 한번 보시죠. 

<p style="outline-width:thin; outline-style:solid;">
This text is having thin outline.
</p>
<br />
<p style="outline-width:thick; outline-style:solid;">
This text is having thick outline.
</p>
<br />
<p style="outline-width:5px; outline-style:solid;">
This text is having 5x outline.
</p>

 

결과는 아래와 같습니다.

This text is having thin outline.


This text is having thick outline.


This text is having 5x outline.

 


The outline-style Property:

The outline-style property specifies the style for the line (solid, dotted, or dashed) that goes around an element. It can take one of the following values:

  • none: No border. (Equivalent of outline-width:0;)

  • solid: Outline is a single solid line.

  • dotted: Outline is a series of dots.

  • dashed: Outline is a series of short lines.

  • double: Outline is two solid lines.

  • groove: Outline looks as though it is carved into the page.

  • ridge: Outline looks the opposite of groove.

  • inset: Outline makes the box look like it is embedded in the page.

  • outset: Outline makes the box look like it is coming out of the canvas.

  • hidden: Same as none.

 

다음 예제를 한번 보시죠.

<p style="outline-width:thin; outline-style:solid;">
This text is having thin solid  outline.
</p>
<br />
<p style="outline-width:thick; outline-style:dashed;">
This text is having thick dashed outline.
</p>
<br />
<p style="outline-width:5px;outline-style:dotted;">
This text is having 5x dotted outline.
</p>

 

결과는 아래와 같습니다.

This text is having thin solid outline.


This text is having thick dashed outline.


This text is having 5x dotted outline.

 


The outline-color Property:

The outline-color property allows you to specify the color of the outline. Its value should either be a color name, a hex color, or an RGB value, as with the color and border-color properties.

 

다음 예제를 한번 보시죠.

<p style="outline-width:thin; outline-style:solid;
             outline-color:red">
This text is having thin solid red  outline.
</p>
<br />
<p style="outline-width:thick; outline-style:dashed;
             outline-color:#009900">
This text is having thick dashed green outline.
</p>
<br />
<p style="outline-width:5px;outline-style:dotted;
             outline-color:rgb(13,33,232)">
This text is having 5x dotted blue outline.
</p>

 

결과는 아래와 같습니다.

This text is having thin solid red outline.


This text is having thick dashed green outline.


This text is having 5x dotted blue outline.

 


The outline Property:

The outline property is a shorthand property that allows you to specify values for any of the three properties discussed previously in any order but in a single statement.

 

다음 예제를 한번 보시죠.

<p style="outline:thin solid red;">
This text is having thin solid red outline.
</p>
<br />
<p style="outline:thick dashed #009900;">
This text is having thick dashed green outline.
</p>
<br />
<p style="outline:5px dotted rgb(13,33,232);">
This text is having 5x dotted blue outline.
</p>

 

결과는 아래와 같습니다.

This text is having thin solid red outline.


This text is having thick dashed green outline.


This text is having 5x dotted blue outline.

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_outlines.htm 

 

 

 

 

💻 Programming/CSS

[CSS] 16. Cursor ( 마우스 커서 모양 )

CSS에서는 커서의 모양을 설정할 수 있는 cursor 속성을 제공합니다. 

이 속성은 submit버튼을 누를때 마치 링크가 걸려있을 때 손가락이 보이는 것처럼 설정을 해줄 수 있도록 해줍니다.  

 

아래 테이블에는 커서 속성이 가질 수 있는 값들에 대한 설명이 나와있습니다.

ValueDescription
autoShape of the cursor depends on the context area it is over. For example an I over text, a hand over a link, and so on...
crosshairA crosshair or plus sign
defaultAn arrow
pointerA pointing hand (in IE 4 this value is hand)
moveThe I bar
e-resizeThe cursor indicates that an edge of a box is to be moved right (east)
ne-resizeThe cursor indicates that an edge of a box is to be moved up and right (north/east)
nw-resizeThe cursor indicates that an edge of a box is to be moved up and left (north/west)
n-resizeThe cursor indicates that an edge of a box is to be moved up (north)
se-resizeThe cursor indicates that an edge of a box is to be moved down and right (south/east)
sw-resizeThe cursor indicates that an edge of a box is to be moved down and left (south/west)
s-resizeThe cursor indicates that an edge of a box is to be moved down (south)
w-resizeThe cursor indicates that an edge of a box is to be moved left (west)
textThe I bar
waitAn hour glass
helpA question mark or balloon, ideal for use over help buttons
<url>The source of a cursor image file

 

그럼 다음 예제를 한번 보도록 하죠.

<p>각 속성값 명칭 위에 마우스를 올려보세요. 마우스 커서모양이 변하는 것을 보실 수 있을 겁니다.</p>
<div style="cursor:auto">Auto</div>
<div style="cursor:crosshair">Crosshair</div>
<div style="cursor:default">Default</div>
<div style="cursor:pointer">Pointer</div>
<div style="cursor:move">Move</div>
<div style="cursor:e-resize">e-resize</div>
<div style="cursor:ne-resize">ne-resize</div>
<div style="cursor:nw-resize">nw-resize</div>
<div style="cursor:n-resize">n-resize</div>
<div style="cursor:se-resize">se-resize</div>
<div style="cursor:sw-resize">sw-resize</div>
<div style="cursor:s-resize">s-resize</div>
<div style="cursor:w-resize">w-resize</div>
<div style="cursor:text">text</div>
<div style="cursor:wait">wait</div>
<div style="cursor:help">help</div>

 

결과는 아래와 같습니다.

각 속성값 명칭 위에 마우스를 올려보세요. 마우스 커서모양이 변하는 것을 보실 수 있을 겁니다.
Auto
Crosshair
Default
Pointer
Move
e-resize
ne-resize
nw-resize
n-resize
se-resize
sw-resize
s-resize
w-resize
text
wait
help

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_cursors.htm 

 

 

 

 

💻 Programming/CSS

[CSS] 15. Paddings ( 패딩 )

이번에는 패딩에 대해서 알아보도록 하겠습니다. 패딩은 내용과 테두리 사이의 간격을 말합니다. 이전에 여백( 또는 마진)에 대해서 공부한 적이 있었죠? 마진과 패딩의 차이가 무엇인지 아시겠죠? 잘 모르시겠다구요? 그럼 일단 패딩 관련된 속성에는 어떤 것들이 있는지 한번 보도록 합시다. 패딩 속성에 대한 속성값은 길이, 퍼센티지, 또는 inherit입니다.  inherit 는 부모의 그 값과 동일하게 한다는 의미입니다.퍼센티지 값이 사용되었다면 내용물이 들어있는 컨텐트 박스 안에서의 퍼센티지입니다.

다음은 패딩관련 속성들 입니다.

  • padding-bottom  

  • padding-top  

  • padding-left  

  • padding-right  

  • padding  

그럼 이제 각 속성에 대한 예제를 보러 가 봅시다~~~ Go Go Go ~


The padding-bottom Property:

The padding-bottom property sets the bottom padding (space) of an element. This can take a value in terms of length of %.

 

다음 예제를 한번 볼까요. 

<p style="padding-bottom: 15px; border:1px solid black;">
This is a paragraph with a specified bottom padding
</p>

<p style="padding-bottom: 5%; border:1px solid black;">
This is another paragraph with a specified bottom padding in percent
</p>

 

결과는 아래와 같습니다.

This is a paragraph with a specified bottom padding

This is another paragraph with a specified bottom padding in percent

 


The padding-top Property:

The padding-top property sets the top padding (space) of an element. This can take a value in terms of length of %.

 

다음 예제한번 볼까요.

<p style="padding-top: 15px; border:1px solid black;">
This is a paragraph with a specified top padding
</p>

<p style="padding-top: 5%; border:1px solid black;">
This is another paragraph with a specified top padding in percent
</p>

 

결과는 아래와 같습니다.

This is a paragraph with a specified top padding

This is another paragraph with a specified top padding in percent

 


The padding-left Property:

The padding-left property sets the left padding (space) of an element. This can take a value in terms of length of %.

 

다음 예제를 한번 볼까요.

<p style="padding-left: 15px; border:1px solid black;">
This is a paragraph with a specified left padding
</p>

<p style="padding-left: 15%; border:1px solid black;">
This is another paragraph with a specified left padding in percent
</p>

 

결과는 아래와 같습니다.

This is a paragraph with a specified left padding

This is another paragraph with a specified left padding in percent

 


The padding-right Property:

The padding-right property sets the right padding (space) of an element. This can take a value in terms of length of %.

 

다음 예제를 한번 볼까요.

<p style="padding-right: 15px; border:1px solid black;">
This is a paragraph with a specified right padding
</p>

<p style="padding-right: 5%; border:1px solid black;">
This is another paragraph with a specified right padding in percent
</p>

 

결과는 아래와 같습니다.

This is a paragraph with a specified right padding

This is another paragraph with a specified right padding in percent

 


The padding Property:

The padding property sets the left, right, top and bottom padding (space) of an element. This can take a value in terms of length of %.

 

다음 예제를 한번 볼까요.

<p style="padding: 15px; border:1px solid black;">
all four padding will be 15px
</p>

<p style="padding:10px 2%; border:1px solid black;">
top and bottom padding will be 10px, left and right padding will be 2% of the total width of the document.
</p>

<p style="padding: 10px 2% 10px; border:1px solid black;"> top padding will be 10px, left and right padding will be 2% of the total width of the document, bottom padding will be 10px </p>

<p style="padding: 10px 2% 10px 10px; border:1px solid black;"> top padding will be 10px, right padding will be 2% of the total width of the document, bottom padding and top padding will be 10px
</p>

 

결과는 아래와 같습니다.

all four paddings will be 15px

top and bottom paddings will be 10px, left and right paddings will be 2% of the total width of the document.

top padding will be 10px, left and right padding will be 2% of the total width of the document, bottom padding will be 10px

top padding will be 10px, right padding will be 2% of the total width of the document, bottom padding and top padding will be 10px

 

 

 

 

 

 

Reference :  http://www.tutorialspoint.com/css/css_padding.htm

 

 

 

 

💻 Programming/CSS

[CSS] 14. Lists ( 리스트, 목록 )

이번에는 목록과 관련된 CSS속성에 대해서 알아보도록 하겠습니다. 

우선 어떤 속성들이 있는지 그놈들의 이름부터 한번 살펴봅시다. 

  • list-style-type 이건 목록 스타일, 예를 들면 숫자, 영문, 동그라미, 사각형 , 뭐 이런 것들을 설정하는 속성입니다. 

  • list-style-position 이건 목록이 인덴트 되어야 하는지를 결정하는 속성입니다. 하위 목록이냐 아니냐 뭐 이런거죠. 

  • list-style-image 목록 앞에 이미지를 보여주겠다는 겁니다. 단순한 숫자목록이나 기호목록이 싫다면 이걸 쓸 수도 있겠네요.

  • list-style 목록 관련 스타일을 한꺼번에 정의할 수 있게 해주는 속성이죠.

  • marker-offset 목록에서 마커(숫자, 동글라미 등등)와 텍스트 사이의 간격을 결정짓는 속성입니다.

이제 각 속성들을 어떻게 사용하는지 예제를 한번 볼까요?? 


The list-style-type Property:

list-style-type 속성은 뭐 목록에 보여지는 마커의 스타일을 변경하기위한 속성입니다. 

목록에는 크게 순서있는 목록과 순서없는 목록이 있죠.

 

다음은 순서없는 목록에서 사용할 수 있는 list-style-type의 속성값입니다. 

ValueDescription
noneNA
disc (default)A filled-in circle
circleAn empty circle
squareA filled-in square

 

다음은 순서있는 목록에서 사용되는 속성값입니다. 

ValueDescriptionExample
decimalNumber1,2,3,4,5
decimal-leading-zero0 before the number01, 02, 03, 04, 05
lower-alphaLowercase alphanumeric charactersa, b, c, d, e
upper-alphaUppercase alphanumeric charactersA, B, C, D, E
lower-romanLowercase Roman numeralsi, ii, iii, iv, v
upper-roman Uppercase Roman numeralsI, II, III, IV, V
lower-greek The marker is lower-greek alpha, beta, gamma
lower-latin The marker is lower-latin a, b, c, d, e
upper-latin The marker is upper-latin A, B, C, D, E
hebrew The marker is traditional Hebrew numbering  
armenian The marker is traditional Armenian numbering  
georgian The marker is traditional Georgian numbering  
cjk-ideographicThe marker is plain ideographic numbers 
hiraganaThe marker is hiraganaa, i, u, e, o, ka, ki
katakanaThe marker is katakanaA, I, U, E, O, KA, KI
hiragana-irohaThe marker is hiragana-irohai, ro, ha, ni, ho, he, to
katakana-irohaThe marker is katakana-irohaI, RO, HA, NI, HO, HE, TO

 

 

예제를 한번 볼까요. 

<ul style="list-style-type:circle;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ul style="list-style-type:square;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol style="list-style-type:decimal;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

<ol style="list-style-type:lower-alpha;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

<ol style="list-style-type:lower-roman;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

결과는 아래와 같습니다. 

  • Maths
  • Social Science
  • Physics
  • Maths
  • Social Science
  • Physics
  1. Maths
  2. Social Science
  3. Physics
  1. Maths
  2. Social Science
  3. Physics
  1. Maths
  2. Social Science
  3. Physics

 


The list-style-position Property:

list-style-position 속성은 bullet point를 포함하는 박스의 내부 또는 외부의 위치를 지정하는 속성입니다.

ValueDescription
noneNA
insideIf the text goes onto a second line, the text will wrap underneath the marker. It will also appear indented to where the text would have started if the list had a value of outside.
outsideIf the text goes onto a second line, the text will be aligned with the start of the first line (to the right of the bullet).

 

다음 예제를 보시죠.

<ul style="list-style-type:circle; list-stlye-position:outside;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ul style="list-style-type:square;list-style-position:inside;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol style="list-style-type:decimal;list-stlye-position:outside;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

<ol style="list-style-type:lower-alpha;list-style-position:inside;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

결과는 아래와 같습니다.

  • Maths
  • Social Science
  • Physics
  • Maths
  • Social Science
  • Physics
  1. Maths
  2. Social Science
  3. Physics
  1. Maths
  2. Social Science
  3. Physics

 


The list-style-image Property:

list-style-image 속성은 위에서 말씀드린 것처럼 이미지 파일을 소스로 지정하여 목록의 마커로 사용할 수 있게끔 해주는 속성입니다.  

 

다음 예제를 보시죠.

<ul>
<li style="list-style-image: url(/images/bullet.gif);">Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol>
<li style="list-style-image: url(/images/bullet.gif);">Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

결과는 아래와 같습니다. ( url에 어떤 이미지 소스의 경로가 들어가느냐에 따라 달라지는 결과입니다. ) 

  • Maths
  • Social Science
  • Physics
  1. Maths
  2. Social Science
  3. Physics

 


The list-style Property:

다음 예제를 보시죠. 

<ul style="list-style: inside square;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol style="list-style: outside upper-alpha;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

결과는 아래와 같습니다.

  • Maths
  • Social Science
  • Physics
  1. Maths
  2. Social Science
  3. Physics

 


The marker-offset Property:

이 속성은 IE 6, Netscape 7 이하에서는 지원하지 않는다는군요.

예제를 봅시다. 

<ul style="list-style: inside square; marker-offset:2em;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ul>

<ol style="list-style: outside upper-alpha; marker-offset:2cm;">
<li>Maths</li>
<li>Social Science</li>
<li>Physics</li>
</ol>

 

결과는 아래와 같습니다.

  • Maths
  • Social Science
  • Physics
  1. Maths
  2. Social Science
  3. Physics

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_lists.htm

 

 

 

 

💻 Programming/CSS

[CSS] 13. Margins ( 마진, 여백 )

margin 속성은 HTML 요소의 주변 공간을 조절합니다. 다른 컨텐트와 오버래핑 할 수도 있습니다. 음수값을 사용한다면 말이죠.

이 속성의 값은 자식 요소에게 상속되지 않습니다. 그리고 주의할 점은 붙어있는 두 요소간의 top, bottom 마진의 경우 중복 적용이 되는 것이 아니라 큰 숫자만 적용이 된다는 것입니다. 이게 무슨 말이냐고요? 천천히 예제를 따라가보도록 해보세요.

다음은 여백 관련 속성입니다.

  • margin 

  • margin-bottom  

  • margin-top  

  • margin-left  

  • margin-right  

이제 하나하나 예제를 통해서 알아보도록 할까요? 


The margin Property:

한방에 끝내는 속성입니다. 모든 마진 관련된 속성값을 넣어서 한번에 설정을 할 수 있습니다.

아래는 p 태그 주변에 마진을 설정할 때의 마진 속성 사용법입니다. 

<style type="text/css">
p {margin: 15px}
all four margins will be 15px

p {margin: 10px 2%}
top and bottom margin will be 10px, left and right margin will be 2% of the total width of the document.

p {margin: 10px 2% -10px}
top margin will be 10px, left and right margin will be 2% of the total width of the document, bottom margin will be -10px

p {margin: 10px 2% -10px auto}
top margin will be 10px, right margin will be 2% of the total width of the document, bottom margin will be -10px, left margin will be set by the browser

</style>

 

예제를 한번 보시죠. 

<p style="margin: 15px; border:1px solid black;">
all four margins will be 15px
</p>

<p style="margin:10px 2%; border:1px solid black;">
top and bottom margin will be 10px, left and right margin will be 2% of the total width of the document.
</p>

<p style="margin: 10px 2% -10px; border:1px solid black;"> top margin will be 10px, left and right margin will be 2% of the total width of the document, bottom margin will be -10px </p>

<p style="margin: 10px 2% -10px auto; border:1px solid black;"> top margin will be 10px, right margin will be 2% of the total width of the document, bottom margin will be -10px, left margin will be set by the browser
</p>

결과는 아래와 같습니다.

all four margins will be 10px

top and bottom margin will be 10px, left and right margin will be 2% of the total width of the document.

top margin will be 10px, left and right margin will be 2% of the total width of the document, bottom margin will be -10px

top margin will be 10px, right margin will be 2% of the total width of the document, bottom margin will be -10px, left margin will be set by the browser

 


The margin-bottom Property:

이건 뭐 말 안해도 아래족 마진 속성이라는 것을 아실겁니다. 속성값으로는 length, % 또는 auto 를 가질 수 있습니다.

<p style="margin-bottom: 15px; border:1px solid black;">
This is a paragraph with a specified bottom margin
</p>

<p style="margin-bottom: 5%; border:1px solid black;">
This is another paragraph with a specified bottom margin in percent
</p>

 

결과는 아래와 같습니다.

This is a paragraph with a specified bottom margin

This is another paragraph with a specified bottom margin in percent

 


The margin-top Property:

위와 동일합니다.
<p style="margin-top: 15px; border:1px solid black;">
This is a paragraph with a specified top margin
</p>

<p style="margin-top: 5%; border:1px solid black;">
This is another paragraph with a specified top margin in percent
</p>

 

결과는 아래와 같습니다.

This is a paragraph with a specified top margin

This is another paragraph with a specified top margin in percent

 


The margin-left Property:

위와 동일합니다.
<p style="margin-left: 15px; border:1px solid black;">
This is a paragraph with a specified left margin
</p>

<p style="margin-left: 5%; border:1px solid black;">
This is another paragraph with a specified top margin in percent
</p>

 

결과는 아래와 같습니다. 

This is a paragraph with a specified left margin

This is another paragraph with a specified top margin in percent



The margin-right Property:

위와 동일합니다.
<p style="margin-right: 15px; border:1px solid black;">
This is a paragraph with a specified right margin
</p>

<p style="margin-right: 5%; border:1px solid black;">
This is another paragraph with a specified right margin in percent
</p>

 

결과는 아래와 같습니다. 

This is a paragraph with a specified right margin

This is another paragraph with a specified right margin in percent

 

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_margins.htm 

 

 

 

 

💻 Programming/CSS

[CSS] 12. Borders ( 테두리, 보더 설정 )

이번 포스팅에서는 테두리에 대한 속성들에 대해서 알아보도록 하겠습니다.

  • border-color 테두리 색상을 설정하는 속성이죠. 

  • border-style 테두리 스타일을 결정짓는 속성이네요.

  • border-width 테두리 두께를 설정하는 속성입니다. 

늘 그렇듯이 역시 예제를 보는게 빨리 배우는 지름길이죠.  

 

시작해 볼까요?? 

The border-color Property:

테두리 색상을 변경할 때는 사방을 한꺼번에 변경할 수도 있겠지만 방향마다 다르게 색상을 지정할 수도 있습니다. 아래와 같은 속성들을 이용해서 말이죠.

  • border-bottom-color

  • border-top-color 

  • border-left-color 

  • border-right-color 

예제를 한번 볼까요?? 

<style type="text/css">
p.example1{
   border:1px solid;
   border-bottom-color:#009900; /* Green */
   border-top-color:#FF0000;    /* Red */
   border-left-color:#330000;   /* Black */
   border-right-color:#0000CC;  /* Blue */
}
p.example2{
   border:1px solid;
   border-color:#009900;        /* Green */
}
</style>
<p class="example1">
This example is showing all borders in different colors.
</p>
<p class="example2">
This example is showing all borders in green color only.
</p>

결과는 아래와 같습니다.

 

 

 

The border-style Property:

테두리 스타일을 내 마음대로 변경할 수 있습니다. 테두리 스타일의 종류로는 아래와 같은 것들이 있습니다.

  • none: No border. (Equivalent of border-width:0;)

  • solid: Border is a single solid line.

  • dotted: Border is a series of dots.

  • dashed: Border is a series of short lines.

  • double: Border is two solid lines.

  • groove: Border looks as though it is carved into the page.

  • ridge: Border looks the opposite of groove.

  • inset: Border makes the box look like it is embedded in the page.

  • outset: Border makes the box look like it is coming out of the canvas.

  • hidden: Same as none, except in terms of border-conflict resolution for table elements.

테두리 스타일 역시 방향에 따라 각기 다른 스타일을 설정할 수 있습니다. 아래 속성들을 이용해서 말이죠. 

  • border-bottom-style 

  • border-top-style 

  • border-left-style 

  • border-right-style 

예제를 한번 보시죠. 

<p style="border-width:4px; border-style:none;">
This is a border with none width.
</p>
<p style="border-width:4px; border-style:solid;">
This is a solid border.
</p>
<p style="border-width:4px; border-style:dashed;">
This is a dahsed border.
</p>
<p style="border-width:4px; border-style:double;">
This is a double border.
</p>
<p style="border-width:4px; border-style:groove;">
This is a groove border.
</p>
<p style="border-width:4px; border-style:ridge">
This is aridge  border.
</p>
<p style="border-width:4px; border-style:inset;">
This is a inset border.
</p>
<p style="border-width:4px; border-style:outset;">
This is a outset border.
</p>
<p style="border-width:4px; border-style:hidden;">
This is a hidden border.
</p>
<p style="border-width:4px; 
             border-top-style:solid;
             border-bottom-style:dashed;
             border-left-style:groove;
             border-right-style:double;">
This is a a border with four different styles.
</p>

결과는 아래와 같습니다.

 

This is a border with none width.

This is a solid border.

This is a dahsed border.

This is a double border.

This is a groove border.

This is aridge border.

This is a inset border.

This is a outset border.

This is a hidden border.

This is a a border with four different styles.

 

 

The border-width Property:

테두리 두께를 내 마음대로 변경할 수 있게끔 해주는 속성입니다. 단위로는 px, pt, cm을 사용할 수도 있고, 정도에 따라 thin, medium, 또는 thick 값을 지정할 수도 있습니다.

이 속성 역시 방향에 따라 각각 부여 할 수 있습니다. 

  • border-bottom-width 

  • border-top-width 

  • border-left-width 

  • border-right-width 

다음 예제를 한번 보시죠. 

<p style="border-width:4px; border-style:solid;">
This is a solid border whose width is 4px.
</p>
<p style="border-width:4pt; border-style:solid;">
This is a solid border whose width is 4pt.
</p>
<p style="border-width:thin; border-style:solid;">
This is a solid border whose width is thin.
</p>
<p style="border-width:medium; border-style:solid;">
This is a solid border whose width is medium;
</p>
<p style="border-width:thick; border-style:solid;">
This is a solid border whose width is thick.
</p>
<p style="border-bottom-width:4px;
             border-top-width:10px;
             border-left-width: 2px;
             border-right-width:15px;
             border-style:solid;">
This is a a border with four different width.
</p>

결과는 아래와 같습니다. 

This is a solid border whose width is 4px.

This is a solid border whose width is 4pt.

This is a solid border whose width is thin.

This is a solid border whose width is medium;

This is a solid border whose width is thick.

This is a a border with four different width.

 

 

Border Properties Using Shorthand:

지금까지 테두리의 색상, 스타일, 그리고 두께에 대해서 속성값을 변경하는 법을 배워보았습니다.

 

그런데 하나하나 지정해주려니 좀 귀찮은 감이 없지않아 있네요.

 

그래서 여기 type less do more를 실천하고있는 방법을 하나 소개해 드리려고 합니다.

 

다음 예제를 한번 보실까요??

<p style="border:4px solid red;">
This example is showing shorthand property for border.
</p>

결과는 아래와 같습니다. 

This example is showing shorthand property for border.

 

위 처럼 두께, 스타일, 색상 속성을 한꺼번에 쓸 수도 있습니다.

 

어때요? 완전 간단하죠? ^_^ 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_borders.htm

 

 

 

 

💻 Programming/CSS

[CSS] 11. Table ( 테이블 설정 )

이번 포스팅에서는 CSS를 이용한 테이블 관련 속성을 설정하는 것을 알아보도록 하겠습니다.

테이블 관련 속성에는 다음과 같은 것들이 있습니다. 

  • border-collapse

  • border-spacing 

  • caption-side 

  • empty-cells 

  • table-layout 

 

이제 이 속성들을 어떻게 사용하는지 한번 볼까요??? ^-^ 

The border-collapse Property:

이 속성은 다음 두가지 값을 가질 수 있습니다. collapse separate.  

다음은 두 가지 값에 대한 예제입니다. 

<style type="text/css">
table.one {border-collapse:collapse;}
table.two {border-collapse:separate;}
td.a {
      border-style:dotted; 
      border-width:3px; 
      border-color:#000000; 
      padding: 10px;
}
td.b {border-style:solid; 
      border-width:3px; 
      border-color:#333333; 
      padding:10px;
}
</style>
<table class="one">
<caption>Collapse Border Example</caption>
<tr><td class="a"> Cell A Collapse Example</td></tr>
<tr><td class="b"> Cell B Collapse Example</td></tr>
</table>
<br />
<table class="two">
<caption>Separate Border Example</caption>
<tr><td class="a"> Cell A Separate Example</td></tr>
<tr><td class="b"> Cell B Separate Example</td></tr>
</table>

직접 테스트 해보세요.

 

Collapse 속성값을 주게되면 테이블 내의 셀들의 보더가 붙어있을 경우 한줄로 보이게 됩니다.

반대로 separate속성값을 주게되면 붙어있는 두 셀의 보더가 따로 떨어져서 보이게 됩니다.

 

 

 

The border-spacing Property:

이 속성은 보더 사이의 간격을 띄우는 속성입니다. 속성값으로는 하나 또는 두개의 값을 가질 수 있고, 이 값은 길이의 단위여야 합니다.

값을 하나만 줄 경우에는 가로, 세로에 동일한 값이 적용이 되며 두개의 값을 줄 경우에는 첫째값이 가로 스페이스, 두번째 값이 세로 스페이스를 위한 값으로 간주됩니다.

NOTE: Netscape 7 또는 IE 6 에서는 적용되지 않는다고 하네요. 아직도 IE 6 사용하는 사람이 있을지는 의문이지만요. 

<style type="text/css">
/* If you provide one value */
table.example {border-spacing:10px;}
/* This is how you can provide two values */
table.example {border-spacing:10px; 15px;}
</style>

앞서 했던 예제의 소스를 변경해보도록 하겠습니다. 

<style type="text/css">
table.one {
   border-collapse:separate;
   width:400px;
   border-spacing:10px;
}
table.two {
   border-collapse:separate;
   width:400px;
   border-spacing:10px 50px;
}
</style>
<table class="one" border="1">
<caption>Separate Border Example with border-spacing</caption>
<tr><td> Cell A Collapse Example</td></tr>
<tr><td> Cell B Collapse Example</td></tr>
</table>
<br />
<table class="two" border="1">
<caption>Separate Border Example with border-spacing</caption>
<tr><td> Cell A Separate Example</td></tr>
<tr><td> Cell B Separate Example</td></tr>
</table>

결과는 아래와 같습니다.

 

직접 테스트 해보는 것 잊지 마세요. 꼭 이요!!! ^-^ 

 

The caption-side Property:

이 속성은 캡션을 어디에 위치시킬 것인지에 대한 속성입니다. 속성값으로는 다음 네가지 중 한개를 가질 수 있습니다. top, bottom, left or right.  그럼 각각의 예제를 한번 볼까요?? 

NOTE: IE 에서는 작동을 안할 수 있다는 군요.

<style type="text/css">
caption.top {caption-side:top}
caption.bottom {caption-side:bottom}
caption.left {caption-side:left}
caption.right {caption-side:right}
</style>

<table style="width:400px; border:1px solid black;">
<caption class="top">
This caption will appear at the top
</caption>
<tr><td > Cell A</td></tr>
<tr><td > Cell B</td></tr>
</table>
<br />

<table style="width:400px; border:1px solid black;">
<caption class="bottom">
This caption will appear at the bottom
</caption>
<tr><td > Cell A</td></tr>
<tr><td > Cell B</td></tr>
</table>
<br />

<table style="width:400px; border:1px solid black;">
<caption class="left">
This caption will appear at the left
</caption>
<tr><td > Cell A</td></tr>
<tr><td > Cell B</td></tr>
</table>
<br />

<table style="width:400px; border:1px solid black;">
<caption class="right">
This caption will appear at the right
</caption>
<tr><td > Cell A</td></tr>
<tr><td > Cell B</td></tr>
</table>

결과는 아래와 같습니다.

 

 

 

The empty-cells Property:

이 속성은 빈 셀과 관련된 속성입니다. 속성값으로는 show, hide, inherit 중에 하나를 가질 수 있습니다. 

<style type="text/css">
table.empty{
    width:350px;
    border-collapse:separate;
    empty-cells:hide;
}
td.empty{
    padding:5px;
    border-style:solid;
    border-width:1px;
    border-color:#999999;
}
</style>
<table class="empty">
<tr>
<th></th>
<th>Title one</th>
<th>Title two</th>
</tr>
<tr>
<th>Row Title</th>
<td class="empty">value</td>
<td class="empty">value</td>
</tr>
<tr>
<th>Row Title</th>
<td class="empty">value</td>
<td class="empty"></td>
</tr>
</table>

 

 

결과는 아래와 같습니다. 

 

 

 

The table-layout Property:

이 속성은 브라우저에 테이블을 보여줄 때 어떻게 보여줄 것인지를 컨트롤 할 수 있게 해주는 속성입니다. 속성값으로는 fixed, auto, 또는 inherit 을 가질 수 있습니다.

 

세가지 값에 대한 차이점을 한번 알아보도록 하죠. 

NOTE: 참고로 이 속성은 많은 브라우저에서 지원하지 않는다고 합니다.

<style type="text/css">
table.auto
{
table-layout: auto
}
table.fixed
{
table-layout: fixed
}
</style>
<table class="auto" border="1" width="100%">
<tr>
<td width="20%">1000000000000000000000000000</td>
<td width="40%">10000000</td>
<td width="40%">100</td>
</tr>
</table>
<br />
<table class="fixed" border="1" width="100%">
<tr>
<td width="20%">1000000000000000000000000000</td>
<td width="40%">10000000</td>
<td width="40%">100</td>
</tr>
</table>

결과는 아래와 같습니다.

 

 

 

 

꼭 스스로 테스트 해보고 결과를 확인하세요.  

 

브라우저 별로 해보고 브라우저의 버전별로 해보고 열심히 공부해야 고수가 될 수 있습니다.

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_tables.htm

 

 

 

 

 

💻 Programming/CSS

[CSS] 10. Links ( 링크 설정 )

이번에는 CSS를 이용한 링크 관련 설정에 대해서 알아보도록 하겠습니다.  

 

  •  :link Signifies unvisited hyperlinks.

  •  :visited Signifies visited hyperlinks.

  •  :hover Signifies an element that currently has the user's mouse pointer hovering over it.

  •  :active Signifies an element on which the user is currently clicking.

이 링크관련 속성은 HTML문서의 헤더부분에 정의를 하시면 됩니다. 그리고 a:hover속성은 a:link 와 a:visited 다음에 와야 합니다. 그리고 a:active속성은 a:hover속성 다음에 와야 합니다. 

<style type="text/css">
a:link {color: #000000}
a:visited {color: #006600}
a:hover {color: #FFCC00}
a:active {color: #FF00CC}
</style>

 

 

 

# 참고로 아래 예제들은 네이버 블로그 특성상 스타일을 먹지 않고 있습니다. 개인적으로 html문서를 만들어서 테스트 해보시기를 권장합니다.

 

 

링크 기본 색상 설정

Following is the example which demonstrates how to set the link color. Possible value could be any color name in any valid format.

<style type="text/css">
a:link {color:#0000FF}
</style>
<a href="/html/index.htm">Black Link</a>

This will produce following black link:

Black Link

 

방문했던 링크 색상 설정

Following is the example which demonstrates how to set the color of visited links. Possible value could be any color name in any valid format.

<style type="text/css">
a:visited {color: #006600}
</style>
<a href="/html/index.htm">Click this link</a>

This will produce following link. Once you will click this link, it will change its color to green.

Click this link

 

마우스 hover시 링크 색상 설정

Following is the example which demonstrates how to change the color of links when we bring a mouse pointer over that link. Possible value could be any color name in any valid format.

<style type="text/css">
a:hover {color: #FFCC00}
</style>
<a href="/html/index.htm">Bring Mouse Here</a>

This will produce following link. Now you bring your mouse over this link and you will see that it changes its color to yellow.

Bring Mouse Here

 

액티브 링크 색상 설정

Following is the example which demonstrates how to change the color of active links. Possible value could be any color name in any valid format.

<style type="text/css">
a:active {color: #FF00CC}
</style>
<a href="/html/index.htm">Click This Link</a>

This will produce following link. This will change it color to pink when user clicks it.

Click This Link

 

 

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_links.htm