[Day6] CSS 6 [11/17]

 

--๋ณต์Šต--

<style>
  .sticky{                             //  sticky ํด๋ž˜์Šค ์„ ํƒ์ž
    position: fixed;               //  ๊ณ ์ •
    top:0;                              //  0
    width: 100%;                   // ๋ถ€๋ชจ 100%
}
</style>
<script>
  var navbar = document.getElementById("navbar");   // 
  // DOM ๋ฉ”์„œ๋“œ getElementById() : ์•„์ด๋””๋ช…์œผ๋กœ ์š”์†Œ๋ฅผ ์–ป์–ด์™€์„œ ๋ณ€์ˆ˜ ์ €์žฅ
  
  console.log( navbar.offsetTop );           
       
  var nbOtop = navbar.offsetTop;            
      
  window.onscroll = function (){	              
	  if (  window.pageYOffset  >= nbOtop ) {
		navbar.classList.add("sticky");             
	} else {
		navbar.classList.remove("sticky");      
	}
  };  
</script>

* ์Šคํฌ๋กค ๋‚ด๋ ค์„œ sticky


css ํ…์ŠคํŠธ ํšจ๊ณผ

     1. ํ…์ŠคํŠธ ์˜ค๋ฒ„ํ”Œ๋กœ( text-overflow )

     2. ์ž๋™ ์ค„ ๋ฐ”๊ฟˆ ( word-wrap )

          - ํ•˜๋‚˜์˜ ๋‹จ์–ด๊ฐ€ ๋„ˆ๋ฌด ๊ธธ์ด์„œ ๋„ˆ๋น„ ๋ณด๋‹ค ์˜ค๋ฒ„ํ”Œ๋กœ์›Œ ๋ฐœ์ƒ.

          - ๊ฐ•์ œ ์ค„ ๋ฐ”๊ฟˆ ์‹œ์ผœ์•ผ ๊ฒ ๋‹ค. 

     3. ์ค„๋ฐ”๊ฟˆ ๊ทœ์น™ ( word-break )

<style>
   p{
      width: 200px;
      border: 1px solid black;
   }
   
   p.test1{
      /* ํ…์ŠคํŠธ ์˜ค๋ฒ„ํ”Œ๋กœ์›Œ */
      white-space: nowrap;
      overflow: hidden;
      text-overflow: clip;  /* ํด๋ฆฝ, ์ž˜๋ผ๋‚ด๋‹ค */
   }
   p.test2{
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;    /* ์ƒ๋žตํ•˜๋‹ค         ...  */
      
      /* ๊ธด๋ฌธ์ž์—ด.substring(0,25).concat("...") */
   }
   
   /* ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ฆด๋•Œ ์˜ค๋ฒ„ํ”Œ๋กœ๋œ ์ฝ˜ํ…์ธ ๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๋ฐฉ๋ฒ• */
   p.test2:hover{
      overflow: visible;
   }
</style>
<style>
   p.test3{
      word-wrap:break-word;
      
      word-break:break-all; 
   }
</style>
 <!-- p.test$*2>lorem10 -->
 <p class="test1">
   Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro adipisci!
 </p>
 <p class="test2">
   Dolor asperiores doloribus amet architecto sint et eius provident quisquam!
 </p>
 
 <p class="test3">
   Dolorum deserunt ducimusquoconsequunturalias esse ex quaerat dignissimos!
</p>

* white-space : nowrap - ์ž๋™ ๊ฐœํ–‰ํ•˜์ง€ ์•Š๊ณ  ์ค„๊ธ€๋กœ ์ซ™

* text-overflow : ellipsis - ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ ๋œ ๋ถ€๋ถ„ ์ƒ๋žต๋จ

   text-overflow : clip - ์ž˜๋ผ๋ƒ„

     4. writing-mode  ์ˆ˜ํ‰/์ˆ˜์ง ํ…์ŠคํŠธ ๋ฐฐ์น˜(์ถœ๋ ฅ) ์ง€์ • ์†์„ฑ

<style>
     p.test1{
        writing-mode:horizontal-tb;   /* ๊ฐ€๋กœ ์“ฐ๊ธฐ ๋ชจ๋“œ */
     }
     p.test3{
        writing-mode:vertical-rl;   /* ์„ธ๋กœ ์“ฐ๊ธฐ ๋ชจ๋“œ */
     }
     p.test2 > span{
         writing-mode:vertical-rl;
     }
</style>
<p class="test1">Lorem ipsum dolor sit amet.</p>
<p class="test2">Sequi <span>laborum</span> reprehenderit ipsum dolorem.</p>
<p class="test3">Repudiandae illo dicta quae ad.</p>

css ์›น ๊ธ€๊ผด

[ css ์›น ๊ธ€๊ผด ]

  ํด๋ผ์ด์–ธํŠธ์— ์„ค์น˜ ๋˜์ง€ ์•Š์€ ๊ธ€๊ผด -> ์›น ๊ธ€๊ผด

  ์ž๋™์œผ๋กœ ์›น ์„œ๋ฒ„์—์„œ ๊ธ€๊ผด ๋‹ค์šด๋กœ๋“œ -> ํด๋ผ์ด์–ธํŠธ์—์„œ ๊ธ€๊ผด ์‚ฌ์šฉ.

  

  [๋‹ค์–‘ํ•œ ๊ธ€๊ผด ํ˜•์‹]

  1. ํŠธ๋ฃจํƒ€์ž…๊ธ€๊ผด( TTF ) - 1980๋…„๋Œ€ ํ›„๋ฐ˜  Apple/MS ๊ฐœ๋ฐœํ•œ ํ‘œ์ค€ ๊ธ€๊ผด ํ˜•์‹

  2. ์˜คํ”ˆํƒ€์ž…๊ธ€๊ผด( OTF ) - TTF ํ˜•์‹ ๊ธฐ๋ฐ˜์˜ ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ๊ธ€๊ผด ํ˜•์‹( MS ๋“ฑ๋ก ์ƒํ‘œ )

  3. ์›น ์˜คํ”ˆ ๊ธ€๊ผดํ˜•์‹( WOFF ) - ์›น ํŽ˜์ด์ง€์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ ๊ธ€๊ผด ํ˜•์‹

  4. SVG ๊ธ€๊ผด

  5. ์ž„๋ฒ ๋””๋“œ ์˜คํ”ˆ ํƒ€์ž…( EOT)

 

<style>
   @font-face{
      font-family: myFirstWebFont;
      src:url('../images/sansation_bold.woff');
      font-weight: bold;
   }
    *{
       font-family: myFirstWebFont;
    }
</style>

- ์„œ๋ฒ„์—์„œ ๋ฐ›์•„์„œ ์‚ฌ์šฉํ•˜๊ฒ ๋‹ค๋Š” ๊ฒƒ

<h1>@font-face ๊ทœ์น™(Rule)</h1>
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto molestias.</div>
<p><b>Note : </b>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo optio dolor a consequatur error eaque laborum in doloribus fugit nesciunt praesentium provident possimus esse laboriosam ducimus dolorum vero saepe libero.</p>

css 2D ๋ณ€ํ™˜ (transform)

  css 2D ๋ณ€ํ™˜ -    ์š”์†Œ๋ฅผ ์ด๋™, ํšŒ์ „, ๋น„์œจ ์กฐ์ •, ๊ธฐ์šธ๊ธฐ.

  transform ์†์„ฑ

  

    1) translate()      ์ด๋™

    2) rotate()          ํšŒ์ „ 

  div{
     width: 300px;
     height: 100px;
     background-color: yellow;
     border:1px solid black;
     
     /* 1. ์š”์†Œ ์ด๋™ :   transform : translate()     ์ˆ˜ํ‰, ์ˆ˜์ง ์ด๋™ */
     /*
     transform: translate(  50px, 100px );
     -ms-transform: translate(  50px, 100px );
     */
     
     /* 2. ์š”์†Œ ํšŒ์ „ rotate()     ์‹œ๊ณ„๋ฐฉํ–ฅ + , ๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ -  ๊ฐ๋„    ํšŒ์ „ */
     /* transform:rotate( 20deg ); */
     /* transform:rotate( -20deg ); */
   }
<input type="radio" name="direction" value="1" checked="checked">์‹œ๊ณ„๋ฐฉํ–ฅ
<input type="radio" name="direction" value="-1">๋ฐ˜์‹œ๊ณ„๋ฐฉํ–ฅ

<br>
<button>ํšŒ์ „ ์‹œ์ž‘</button>
<button>ํšŒ์ „ ๋ฉˆ์ถค</button>
<p>.</p>
<p>.</p>
<p>.</p>
<div>
 Lorem ipsum dolor sit amet, consectetur adipisicing elit.
 Saepe fuga sit aut facere doloremque architecto.
 </div>
<script>
   var angle = 1;  // ํšŒ์ „ ์‹œํ‚ฌ ๊ฐ๋„
   var direction = 1;   // ํšŒ์ „ ์‹œํ‚ฌ ๋ฐฉํ–ฅ     1(์‹œ๊ณ„)   -1(๋ฐ˜์‹œ๊ณ„)
   var timer;
   // [ ํšŒ์ „ ์‹œ์ž‘ ๋ฒ„ํŠผ ]
   // 1๋ฒˆ ํด๋ฆญ 
   document.querySelector("button:first-of-type").onclick = function (){
	   //alert("first");
	   // [ ์ฒดํฌ๋œ ๋ผ๋””์˜ค ๋ฒ„ํŠผ์˜ value ์†์„ฑ ]
	   // direction =  ๋ผ๋””์˜ค๋ฒ„ํŠผ ์‹œ, ๋ฐ˜์‹œ;
	   
	   // 1. ๋ชจ๋“  ๋ผ๋””์˜ค ๋ฒ„ํŠผ 
	   // document.getElementsByTagName("input")
	   // var radios = document.getElementsByName("direction");
	   var radios = document.querySelectorAll("input[name=direction]");
	   // alert( radios.length );
	   for (var i = 0; i < radios.length; i++) {
		  //console.log(   radios[i].checked  +"/" + radios[i].value );
		  if(  radios[i].checked == true){
			  direction = radios[i].value;
		  } // if
		  
	  } // 
	   
	                                    // ํ•จ์ˆ˜ ๋“ฑ๋ก
	  timer = setInterval( div_rotate , 10)
	  
	  this.disabled = "true"; // ๋น„ํ™œ์„ฑํ™”
	  document.querySelector("button:last-of-type").disabled = false;
   }
   
   document.querySelector("button:last-of-type").onclick = function (){
	   //alert("last");
	   clearInterval(timer);
	   
	   this.disabled = "true"; // ๋น„ํ™œ์„ฑํ™”
	   document.querySelector("button:first-of-type").disabled = false;
   }

   function div_rotate(){
	  var target = document.querySelector("div");
	  // css transform:rotate( 20deg );      -> js
	  target.style.transform = "rotate( " + angle + "deg )";
	  
	  // js   "1" -> 1 ๋ณ€ํ™˜
	  // java    Integer.parseInt()
	  angle +=  parseInt( direction   );   //  js     += ๋ณตํ•ฉ๋Œ€์ž…์—ฐ์‚ฐ์ž.
	  console.log( "> angle = " + angle );
   }
</script>

    3) scaleX() / scaleY()   / scale()  ๋น„์œจ ์กฐ์ •

    4) skewX() / skewY() / skew()    ๊ธฐ์šธ๊ธฐ

    5) matrix()   ์•ฝ์‹

<style>
    div{
        width: 300px;
        height: 100px;
        background-color: yellow;
        border:1px solid black;
        
        /*  1  2  0.5 ๋ฐฐ */
        /* 
        transform:scaleX(1.5);
        transform:scaleY(1.5);
         */
        /*  
        transform:scale( 2 ,  0.5 );
         */
         
         /* ์ง€์ •๋œ ๊ฐ๋„๋งŒํผ X ์ถ•์„ ๋”ฐ๋ผ ์š”์†Œ๋ฅผ ๊ธฐ์šธ์ธ๋‹ค. */
         /* transform:skewX( 30deg ); */
         /* transform:skewX( 90deg ); */
         
         /* transform:skewY( 40deg ); */
         
         /* transform:skew( 20deg , 10deg); */
         /* transform:skew( 20deg ); == skew( 20deg, 0) */
      
      
             /* matrix == ํ–‰๋ ฌ , ๋ง , 2D(์ด๋™,ํšŒ์ „X,๋น„์œจ์กฐ์ •,๊ธฐ์šธ๊ธฐ) + ๊ฒฐํ•ฉ*/
             /* ํšŒ์ „ X */
             /* transform:matrix(scaleX, skewY, skewX, scaleY, tranlateX, translateY) */
             transform:matrix(1, -0.3, 0, 1, 0, 0);
    }
</style>

3D ๋ณ€ํ™˜(  x,y,z )

    1. ์š”์†Œ ์ด๋™

         transform:translateX(), 

         transform:translateY(), 

         transform:translateZ(), 

         transform:translate3d(x,y,z) 

    2. ์š”์†Œ ํšŒ์ „

         transform:rotateX()

         transform:rotateY()

         transform:rotateZ()

         transform:rotate3d()

    3. ์š”์†Œ ๋น„์œจ ์กฐ์ •

         transform:scaleX()

         transform:scaleY()

         transform:scaleZ()

         transform:scale3d()

         

    4. ์š”์†Œ ๊ธฐ์šธ๊ธฐ X

    5.  transform:matrix3d(,,,,,,,);

 

<script>
     var angle = 1;  // ํšŒ์ „ ์‹œํ‚ฌ ๊ฐ๋„     
     var timer;
   
     document.querySelector("button:first-of-type").onclick = function (){
    	 timer = setInterval(function() {
    	 	var target = document.getElementById("demo");
    	 	// transform:translateX(),
    	 	/* target.style.transform = "rotateX("+  angle  +"deg)"; */
    	 	/* target.style.transform = "rotateY("+  angle  +"deg)"; */
    	 	target.style.transform = "rotateZ("+  angle  +"deg)";
    	 	
    	 	angle++;   // js    ++,-- ์ฆ๊ฐ์—ฐ์‚ฐ์ž.
    	 }, 10);    	 
     }
</script>

 

2D 3D ๋น„๊ต

<style>
   #rotate2D, #rotate3D{
      width:80px;
      height:70px;
      color:white;
      position:relative;
      font-weight: bold;
      font-size: 15px;
      padding: 10px;
      float: left;
      margin-right:50px;
      border-radius: 5px;
      border:1px solid #000;
      background-color: red;
      margin:10px;  
   }
</style>
<div style="height: 80px;">
	<div id="rotate2D"  onmouseover="rotateDiv1();">2D rotate</div>
	<div id="rotate3D"  onmouseover="rotateDiv2();">3D rotate</div>
</div>
<script>
   var div2D;  // div   id="rotate2D" 
   var div3D;  // div    id="rotate3D" 
   var timer2D;
   var timer3D;
   var angle2D = 0;
   var angle3D = 0;
   
   function  rotateDiv1(){
	   // 2D ํšŒ์ „
	   div2D = document.getElementById("rotate2D");
	   clearInterval(timer2D);
	   timer2D = setInterval(function() {
	   	    angle2D++;
	   	 div2D.style.transform = "rotate("+  angle2D+"deg)";
	   	 div2D.style.webkitTransform = "rotate("+  angle2D+"deg)";
	   	 div2D.style.OTransform = "rotate("+  angle2D+"deg)";
	   	 div2D.style.MozTransform = "rotate("+  angle2D+"deg)";
	   	  
	   	 if( angle2D == 180 || angle2D == 360 ){
	   		 clearInterval(timer2D);
	   	     if( angle2D == 360)
	   		   angle2D = 0;
	   	 }
	   }, 10);
   }
   function  rotateDiv2(){
	   div3D = document.getElementById("rotate3D");
	   
	   clearInterval(timer3D);
	   timer3D = setInterval(function() {
	   	    angle3D++;
	   	 div3D.style.transform = "rotateY("+  angle3D+"deg)";
	   	 div3D.style.webkitTransform = "rotateY("+  angle3D+"deg)";
	   	 div3D.style.OTransform = "rotateY("+  angle3D+"deg)";
	   	 div3D.style.MozTransform = "rotateY("+  angle3D+"deg)";
	   	 
	   	if( angle3D == 180 || angle3D == 360 ){
	   		 clearInterval(timer3D);
	   	     if( angle3D == 360)
	   		   angle3D = 0;
	   	 }
	   	 
	   }, 10);
   }
</script>

    [ ์ „ํ™˜( transition) ]

    1) ์ง€์ •๋œ ๊ธฐ๊ฐ„๋™์•ˆ ์†์„ฑ ๊ฐ’์„ ์›ํ• ํ•˜๊ฒŒ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฒƒ. 

    width:0px;          -> :hover ->      width:180px

    ์˜ˆ)  transition:  0.5s   ease;

    ์˜ˆ)  transition: width 0.5s   ease;

    2)  transition ์•ฝ์‹

    - transition-delay ์†์„ฑ                  X

    - transition-duration ์†์„ฑ        : 0.5s

    - transition-property ์†์„ฑ       : width

    - transition-time-function  ์†์„ฑ       : ease

    

    3) ์ „ํ™˜ ํšจ๊ณผ๋ฅผ ๋งŒ๋“ค๋ ค๋ฉด 2๊ฐ€์ง€ ์„ค์ •.

         (1) ํšจ๊ณผ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ ค๋Š” css ์†์„ฑ

         (2) ํšจ๊ณผ๋ฅผ ์ง€์† ์‹œ๊ฐ„

               ( ์ง€์† ์‹œ๊ฐ„์„ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ๊ธฐ๋ณธ๊ฐ’์€ 0 ์œผ๋กœ ์ ์šฉ๋œ๋‹ค. )

<style>
    div{
       background: red;
       width:100px;
       height:100px;
       
       /* ease ํšจ๊ณผ:  ์‹œ์ž‘(์ฒœ์ฒœํžˆ) -> ๋นจ๋ผ์ง€๊ณ -> ์ข…๋ฃŒ( ์ฒœ์ฒœํžˆ) */
       /* transition:width 2s ease, height 2s ease-in; */
       /* transition: 2s ease; */
       
       /* ์ „ํ™˜ ์ง€์—ฐ ์‹œ๊ฐ„ */
       transition-delay:1s;
       
       transition-property:width;  /* ์ „ํ™˜์†์„ฑ */
       transition-duration: 2s;       /* ์ „ํ™˜๊ธฐ๊ฐ„ */
       transition-timing-function:ease;  /* ์ „ํ™˜์†๋„๊ณก์„  */
    }
    
    div:hover{
       width: 300px;
       height:200px;
    }
</style>

์ „ํ™˜ ์†๋„ ๊ณก์„  : ease ํšจ๊ณผ
        1. ease : ์ฒœ->๋นจ->์ฒœ ( ๊ธฐ๋ณธ๊ฐ’)
        2. linear: ๋“ฑ์†
        3. ease-in : ๋Š๋ฆฐ ์‹œ์ž‘์œผ๋กœ ~ 
        4. ease-out : ๋Š๋ฆฐ ์ข…๋ฃŒ..
        5. ease-in-out : ์ฒœ ์‹œ์ž‘~ ์ฒœ ์ข…๋ฃŒ

  div:nth-of-type(1){  transition-timing-function:ease; }
  div:nth-of-type(2){  transition-timing-function:linear; }
  div:nth-of-type(3){  transition-timing-function:ease-in; }
  div:nth-of-type(4){  transition-timing-function:ease-out; }
  div:nth-of-type(5){  transition-timing-function:ease-in-out; }

 [ ๋ณ€ํ™˜( transform) - ์ด๋™,  ํšŒ์ „, ํฌ๊ธฐ ๋น„์œจ์กฐ์ •, ๊ธฐ์šธ๊ธฐ ]

 

๋ณ€ํ™˜(transform) + ์ „ํ™˜(transition)

   div{
      width: 100px;
      height: 100px;
      background-color: red;
      
      transition:width 2s ease, height 2s ease, transform 2s;
      
      display: inline-block;
   }
   div:hover{
      width: 300px;
      height: 300px;
      
      /* ๋ณ€ํ™˜ - ์ด๋™, ํšŒ์ „, ํฌ๊ธฐ ์กฐ์ •, ๊ธฐ์šธ๊ธฐ (  transform์†์„ฑ  )*/
      transform:rotate(180deg);
   }

css ์• ๋‹ˆ๋ฉ”์ด์…˜

   - js ๋˜๋Š” Flash๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ , html ์š”์†Œ์˜ ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์ฒ˜๋ฆฌ.

   - ์• ๋‹ˆ๋ฉ”์ด์…˜ ? ํ•œ ์Šคํƒ€์ผ์—์„œ ๋‹ค๋ฅธ ์Šคํƒ€์ผ๋กœ ์ ์ฐจ์ ์œผ๋กœ ๋ณ€ํ™˜๋˜๋Š” ๊ฒƒ.

   - css ์†์„ฑ

        @keyframes

        animation-name

        animation-duration

        animation-iteration-count

        animation-direction

        animation-timing-function

        animation-fill-mode        

        animation ์•ฝ์‹ ์†์„ฑ. 

        

        keyframe(ํ‚ค ํ”„๋ ˆ์ž„) ? ํŠน์ • ์‹œ๊ฐ„์— ๊ฐ€์ง€๋Š” ์š”์†Œ์˜ ์Šคํƒ€์ผ

        keyframe(ํ‚ค ํ”„๋ ˆ์ž„) + ..... ์—ฌ๋Ÿฌ ๊ฐœ ์„ ์–ธ...

<style>
  
   div{
      width: 100px;
      height:100px;
      background: red;
      
      animation-name:sample;
      animation-duration:4s; /*  ์• ๋‹ˆ๋ฉ”์ด์…˜์„ ์™„๋ฃŒํ•˜๋Š” ๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„ ์„ค์ • */
      animation-timing-function:linear;  
      /* 
       ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์žฌ์ƒ๋˜์ง€ ์•Š์„ ๋•Œ  ( ์‹œ์ž‘์ „, ์ข…๋ฃŒํ›„) ์š”์†Œ์˜ ์Šคํƒ€์ผ ์ง€์ •
          : forwards  - ๋งˆ์ง€๋ง‰    ํ‚คํ”„๋ ˆ์ž„์˜ ์Šคํƒ€์ผ ์œ ์ง€
          , backwards - ์ฒซ ๋ฒˆ์งธ ํ‚คํ”„๋ ˆ์ž„์˜ ์Šคํƒ€์ผ ์œ ์ง€
          , both, none 
        */
      animation-fill-mode: backwards;
      
      /* animation-delay:2s;  */ /* ์• ๋‹ˆ๋ฉ”์ด์…˜ 2์ดˆ ํ›„์— ์žฌ์ƒ */
      /* animation-delay:-2s; */ /*  ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ด๋ฏธ 2์ดˆ ์žฌ์ƒ๋œ ํ›„~ ์‹œ์ž‘ */ 
      /* animation-iteration-count:3;  */  /* ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฐ˜๋ณต ํšŸ์ˆ˜ */
        animation-iteration-count: infinite; /* ๋ฌดํ•œ ๋ฐ˜๋ณต */
      
      /* 
      ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฐฉํ–ฅ 
      : normal ( ๊ธฐ๋ณธ๊ฐ’)
      : reverse( ์—ญ๋ฐฉํ–ฅ)
      :alternate( ์•ž->๋’ค-> ์•ž)
      :alternate-reverse
       */
      /* animation-direction: reverse; */
      animation-direction: alternate;
      
      /* div ์š”์†Œ๋ฅผ ์ด๋™ - left, top  */
     position: relative;
   }
   
   @keyframes sample {
      /* 
	  from {background-color: red }
	  to {background-color: yellow }
	   */
	   
	  0% {background-color: red;  left:0 ; top:0; }
	  25% {background-color: green;  left:200px ; top:0; }
	  50% {background-color: blue;  left:200px ; top:200px; }
	  75% {background-color: yellow;  left:0 ; top:200px; }
	  100% {background-color: red;  left:0 ; top:0;}
	}
</style>

 ์ข€ ๋” ์‰ฝ๊ฒŒ ์†์„ฑ๊ฐ’์œผ๋กœ ํ‘œํ˜„

   div{
      width: 100px;
      height:100px;
      background: red;
                 /* 6 ๊ฐœ์˜ ์†์„ฑ */
                  /* name  , duration, timing function, delay, iteration-count, direction */
      animation:sample 4s linear 2s infinite alternate;   
      
      /* div ์š”์†Œ๋ฅผ ์ด๋™ - left, top  */
     position: relative;
   }
   
   @keyframes sample {
	  0% {background-color: red;  left:0 ; top:0; }
	  25% {background-color: green;  left:200px ; top:0; }
	  50% {background-color: blue;  left:200px ; top:200px; }
	  75% {background-color: yellow;  left:0 ; top:200px; }
	  100% {background-color: red;  left:0 ; top:0;}
	}

๋กœ๋”ฉ & ํ”๋“ค๊ธฐ

<style>
   .loader{
       width: 120px;
       height:120px;
       border:16px solid #f3f3f3;
       border-top-color: red;
       
       border-radius: 50%;
       
       animation:spin 1.5s linear infinite;
   }
   
   @keyframes spin{
       from{ transform:rotate(0deg); }
       to { transform:rotate(360deg); }
   }
</style>
<style>
   img{
     width:150px;
     border: 1px  solid #ddd;
     padding:5px;
     border-radius: 4px;
   }
   img:hover{
     box-shadow: 0 0 2px  1px   rgba(0, 240, 186, 0.5);
     
     /* css ์• ๋‹ˆ๋ฉ”์ด์…˜ ์ฒ˜๋ฆฌ : ์ด๋ฏธ์ง€(์ฐฝ) ํ”๋“ค๊ธฐ */
     animation:shake 0.5s infinite;
   }
   
   @keyframes shake{
       0% { transform:translate(1px, 1px) rotate(0deg); }
      10% { transform:translate(-1px, -1px) rotate(-1deg); } 
     20% { transform:translate(3px, 0px) rotate(1deg); } 
     30% { transform:translate(3px, 2px) rotate(0deg); } 
     40% { transform:translate(1px, -1px) rotate(1deg); } 
     50% { transform:translate(-1px, 1px) rotate(-1deg); } 
     60% { transform:translate(2px, -1px) rotate(0deg); } 
     70% { transform:translate(-1px, 1px) rotate(1deg); } 
     80% { transform:translate(3px, -1px) rotate(-1deg); } 
     90% { transform:translate(1px, 3px) rotate(0deg); } 
     100% { transform:translate(1px, -2px) rotate(-1deg); } 
   }
 </style>

css ํˆดํŒ(tooltip)

 

    [css ํˆดํŒ(tooltip)]

    ์š”์†Œ ์œ„์— ๋งˆ์šฐ์Šค ํฌ์ธํ„ฐ๋ฅผ ์ด๋™ํ•  ๋•Œ

    ๊ทธ ์š”์†Œ์˜ ์ถ”๊ฐ€ ์ •๋ณด๋ฅผ ํ’์„ ๋„์›€๋ง๋กœ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฒƒ.

    

    == ๋“œ๋กญ๋‹ค์šด ๋ฉ”๋‰ด

<style>
   body{
      text-align: center;
   }
   .tooltip{
      position: relative;
      border-bottom: 1px dotted black;
      display: inline-block;
   }
   .tooltip .tooltiptext{
      position: absolute;
      z-index:1;
      left:50%;
      /* top:100%; */ 
      bottom:130%;
      
      /*  ๋ณ€ํ™˜(transform) - ์ด๋™, ํšŒ์ „, ํฌ๊ธฐ๋น„์œจ์กฐ์ •, ๊ธฐ์šธ๊ธฐ */
      transform:translateX(-50%);
      
      background-color: black;
      color:white;
      width: 120px;
      text-align: center;
      border-radius: 6px;
      padding: 5px 0;
      
      visibility: hidden;
   }
   
    .tooltip .tooltiptext::after{
       content:"";
       
       border-style: solid;
       border-width: 5px;
       border-color:black transparent transparent transparent;
       
       position:absolute;
       top:100%;
       left:50%;
       transform:translateX(-50%);
    }
   
   .tooltip:hover .tooltiptext{
      visibility: visible;
   }
</style>

- after ๋ถ€๋ถ„์ด ํˆดํŒ ๋พฐ์กฑ

<!-- p*5>{.} -->
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>
<p>.</p>

<!-- .tooltip>span.tooltiptext -->
<div class="tooltip">Hover over me
    <span class="tooltiptext">Tooltip Text Sample</span>
</div>

 

ex2) ํˆดํŒ ๋พฐ์กฑ ๋งŒ๋“ค๊ธฐ

<style>
  div{
     box-sizing: border-box;
     width: 40px;
     height: 40px;
     /* 
     border-top: 20px solid red;
     border-right: 20px solid green;
     border-bottom: 20px solid blue;     
     border-left: 20px solid yellow;
      */
      
     border-style:solid;
     border-width:20px; 
     /* transparent == ํˆฌ๋ช…ํ•œ */
     border-color: red transparent  transparent  transparent;
  }
</style>

ex3 ์œ„์น˜์กฐ์ •)

<style>
   body{
      text-align: center;
   }
   .tooltip{
      position: relative;
      border-bottom: 1px dotted black;
      display: inline-block;
   }
   .tooltip .tooltiptext{
      position: absolute;
      z-index:1;
      left:110%;
      top: -50%;
      
      
      background-color: black;
      color:white;
      width: 120px;
      text-align: center;
      border-radius: 6px;
      padding: 5px 0;
      
      /* visibility: hidden; */
   }
   
    .tooltip .tooltiptext::after{
       content:"";
       
       border-style: solid;
       border-width: 5px;
       border-color: transparent  black transparent transparent;
       
       position:absolute;
       right: 100%;
       top:50%;
       
       transform:translateY(-50%);
       
    }
   
   .tooltip:hover .tooltiptext{
      visibility: visible;
   }
</style>

๋ทฐํฌํŠธ(viewport), ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ

 

[๋ทฐํฌํŠธ(viewport)]

    1. ์›น ํŽ˜์ด์ง€์—์„œ ์‚ฌ์šฉ์ž๊ฐ€ ๋ณผ ์ˆ˜ ์žˆ๋Š” ์˜์—ญ

    2. ํ‘œ์‹œ ์˜์—ญ์€ ๋””๋ฐ”์ด์Šค(์žฅ์น˜)์— ๋”ฐ๋ผ ํ™”๋ฉด์˜ ํฌ๊ธฐ๊ฐ€ ๋‹ค๋ฅด๋‹ค. 

    3. ์Šค๋งˆํŠธํฐ, ํ…Œ๋ธ”๋ฆฟ, ์ปดํ“จํ„ฐ ํ™”๋ฉด - ๋ทฐํฌํŠธ X

    4. ์—ฌ๋Ÿฌ ์žฅ์น˜์—์„œ ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์›น ํŽ˜์ด์ง€๋ฅผ ์žฅ์น˜ํ™”๋ฉด์— ๋งž๊ฒŒ ์ถ•์†Œ, ํ™•๋Œ€..

    5. ์žฅ์น˜์˜ ํฌ๊ธฐ ๋ฐฐ์œจ์— ๋งž๊ฒŒ ์›นํŽ˜์ด์ง€์˜ ํฌ๊ธฐ ์ œ์–ด...

        ๋ทฐํฌํŠธ ์„ค์ •.

      <meta name="viewport" content="width=device-width, initial-scale=1.0">

      

      - width=device-width  ์žฅ์น˜์˜ ํ™”๋ฉด ๋„ˆ๋น„๋ฅผ ๋”ฐ๋ผ์„œ ์›น ํŽ˜์ด์ง€ ๋„ˆ๋น„ ์„ค์ •.

      - initial-scale=1.0         ๋ธŒ๋ผ์šฐ์ €์—์„œ ํŽ˜์ด์ง€๋ฅผ ์ฒ˜์Œ ๋กœ๋“œํ•  ๋•Œ์˜ ์ดˆ๊ธฐ ํ™•๋Œ€/์ถ•์†Œ ์ˆ˜์ค€ ์„ค์ •

 

[๋ฏธ๋””์–ด ์ฟผ๋ฆฌ]

   1. css2 ์—  ๋„์ž… @media๊ทœ์น™

   2. ๋‹ค์–‘ํ•œ ๋ฏธ๋””์–ด ์œ ํ˜•์— ๋”ฐ๋ผ ์„œ๋กœ ๋‹ค๋ฅธ ์Šคํƒ€์ผ ์ ์šฉ ์ •์˜ 

      ๋‹ค์–‘ํ•œ ๋ฏธ๋””์–ด ์œ ํ˜• ? ์ปดํ“จํ„ฐ ํ™”๋ฉด์šฉ, ํ”„๋ฆฐํ„ฐ ์šฉ,  ํœด๋Œ€ํฐ, ํ…”๋ ˆ๋น„์ ผ ๋“ฑ๋“ฑ

   3. css3 = css2 ๋ฏธ๋””์–ด ์œ ํ˜• + ํ™•์žฅ    

   4. ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ๋Š”  [๋ฌด์–ธ๊ฐ€๋ฅผ ํ™•์ธ] ํ›„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

        1) ๋ทฐํฌํŠธ์˜ ๋„ˆ๋น„, ๋†’์ด

        2) ์žฅ์น˜์˜ ๋„ˆ๋น„, ๋†’์ด

        3) ๋ฐฉํ–ฅ( ํ…Œ๋ธ”๋ฆฟ, ํœด๋Œš๋…ธ์˜ ๊ฐ€๋กœ ๋˜๋Š” ์„ธ๋กœ ๋ชจ๋“œ)

        4) ๋“ฑ๋“ฑ

        

    5. ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•ด์„œ    ๋ฐ˜์‘ํ˜• ์›น ๊ตฌํ˜„...

    

    6. ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ ๊ตฌ๋ฌธ ํ˜•์‹  ์ฒซ๋ฒˆ์งธ 

    @media  not|only ๋ฏธ๋””์–ด์žฅ์น˜์œ ํ˜•   and  ( true/false ํ‘œํ˜„์‹){

          css ์ฝ”๋”ฉ;

    } 

      ์˜ˆ) @media  only screen and ( max-width:700px ){

           css ์ฝ”๋”ฉ

      }

      

      @media   ( max-width:700px ){

           css ์ฝ”๋”ฉ

      }

         ใ„ฑ. ๋ฏธ๋””์–ด์žฅ์น˜์œ ํ˜• : screen, print, speech ๋“ฑ๋“ฑ

      

     6. ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ ๊ตฌ๋ฌธ ํ˜•์‹  ๋‘ ๋ฒˆ์งธ

      <link red="stylesheet" href="screen.css"  media="not|only ๋ฏธ๋””์–ด์žฅ์น˜์œ ํ˜•   and  ( true/false ํ‘œํ˜„์‹" >     

  • ๋„ค์ด๋ฒ„ ๋ธ”๋Ÿฌ๊ทธ ๊ณต์œ ํ•˜๊ธฐ
  • ๋„ค์ด๋ฒ„ ๋ฐด๋“œ์— ๊ณต์œ ํ•˜๊ธฐ
  • ํŽ˜์ด์Šค๋ถ ๊ณต์œ ํ•˜๊ธฐ
  • ์นด์นด์˜ค์Šคํ† ๋ฆฌ ๊ณต์œ ํ•˜๊ธฐ