½ÃÀÛÆäÀÌÁö·Î Áñ°Üã±âÃß°¡
·Î±×ÀÎ
ȸ¿ø°¡ÀÔ l Ã⼮üũ l ¸¶ÀÌÆäÀÌÁö l CGIMALL
Vue.js ¹ÝÀÀÇü ¼ÅÇà À̹ÌÁö °¶·¯¸® : happycgi
ÀÚ·á½Ç »çÀÌÆ®µî·Ï ·©Å·100 ÇÁ·Î±×·¥¸®ºä °ü¸®ÀÚÃßõÀÚ·á Ãʺ¸°¡À̵å
Ä¿¹Â´ÏƼ
Àüü ÆîÃ帱â
Äü¸Þ´º¸µÅ© jquery , CSS , PHP , Javascript , ¹«·áÆùÆ® , ASP
»ó¼¼°Ë»ö
Ȩ > CSS > ±âº» ¼Ò½º > Vue.js ¹ÝÀÀÇü ¼ÅÇà À̹ÌÁö °¶·¯¸® »ó¼¼Á¤º¸
»çÀÌÆ®µî·Ï
Ŭ¶ó¿ìµåű×
Javascript
HTML
PHP
css
API
mysql
ASP
jquery
image
Slide
¸Þ´º
mobile
°Ô½ÃÆÇ
ÇöÀçÁ¢¼ÓÀÚ ¸í »õ·Î°íħ
Vue.js ¹ÝÀÀÇü ¼ÅÇà À̹ÌÁö °¶·¯¸®
¼Ò½ºÅë°èÁ¤º¸ ¿À·ù½Å°í ¹× ¹®ÀÇ
ÇØÇÇÆÀ
³×ƼÁð
Æ®À§ÅÍ·Î º¸³»±â ÆäÀ̽ººÏÀ¸·Î º¸³»±â
¼Ò½ººÐ·ù ±âº» ¼Ò½º
´Ù¿î·Îµå Ƚ¼ö 7 ȸ
°£´Ü¼³¸í Vue.js¸¦ Ȱ¿ëÇØ ¹ÝÀÀÇüÀ¸·Î µ¿ÀÛÇϸç, À̹ÌÁö ¹è¿­À» ¼ÅÇÃ(Shuffle)ÇÏ´Â °¶·¯¸®
Æò°¡Çϱâ ÈǸ¢ÇÔ ¸Å¿ìÁÁÀ½ ÁÁÀ½ ±¦ÂúÀ½ º¸Åë º°·Î
ȨÆäÀÌÁö¹Ù·Î°¡±â ¼Ò½º´Ù¿î·Îµå µ¥¸ð ¹Ì¸®º¸±â ½ºÅ©·¦Çϱâ

Vue.js¸¦ Ȱ¿ëÇØ ¹ÝÀÀÇüÀ¸·Î µ¿ÀÛÇϸç, À̹ÌÁö ¹è¿­À» ¼ÅÇÃ(Shuffle)ÇÏ´Â °¶·¯¸®
ÀÌ CodePen ¿¹Á¦´Â Vue.js¸¦ »ç¿ëÇÏ¿© ¹ÝÀÀÇü ·¹À̾ƿô°ú µ¿ÀûÀÎ À̹ÌÁö ¹è¿­ ±â´ÉÀ» ±¸ÇöÇÑ ¼ÅÇà °¶·¯¸®ÀÔ´Ï´Ù.

Æ÷Æ®Æú¸®¿À °¶·¯¸®, »óǰ À̹ÌÁö ¸ñ·Ï, À̺¥Æ®³ª Ä·ÆäÀÎ »çÁø Àü½Ã Ȱ¿ëÇϸé À¯¿ëÇÕ´Ï´Ù.

HTML ±¸Á¶

<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>


<div id='app'>

  <ul class='gallery'>

    <li

      v-for='item in items'

      :key='item.id'

      :data-pos='item.pos'

      :style='{

        translate: `calc(var(--width) * 0.2 * ${item.pos})`,

        scale: item.scale,

        backgroundImage: `url(${item.url})`

      }'

      @click='shuffle(item)'

    >

    </li>

  </ul>

</div>



CSS ¼Ò½º

:root {

  --width: min(1000px,90vw);

}


* {

  margin: 0;

  padding: 0;

  box-sizing: border-box;

}


#app {

  height: 100vh;

  display: grid;

  place-items: center;

}


.gallery {

  width: min(var(--width));

  list-style-type: none;

  display: grid;


  & li {

    position: relative;

    grid-column: 1;

    grid-row: 1;

    width: calc(var(--width) / 5);

    aspect-ratio: 1;

    cursor: pointer;

    background-position: center;

    background-size: cover;

    background-repeat: no-repeat;

    box-shadow: 0 2px 7px rgba(0,0,0,0.6);

    transition: translate 0.8s, scale 0.8s;

    will-change: transform;


    &::after {

      content: '';

      position: absolute;

      inset: 0;

      background-color: rgba(0,0,0,0.6);

    }

  }


  & li[data-pos='0'] { scale: 1; z-index: 1; }

  & li[data-pos='1'] { scale: 1.4; z-index: 5; }

  & li[data-pos='2'] { scale: 1.8; z-index: 10; }

  & li[data-pos='3'] { scale: 1.4;  z-index: 5; }

  & li[data-pos='4'] { scale: 1; z-index: 1; }


  & li[data-pos='1']::after { background-color: rgba(0,0,0,0.4); }

  & li[data-pos='2']::after { background-color: transparent; }

  & li[data-pos='3']::after { background-color: rgba(0,0,0,0.4); }

}



JS ¼Ò½º

const {createApp,reactive} = Vue;


createApp({

  setup() {

    const items = reactive([

      {id: 0, pos: 0, url: 'https://tinyurl.com/4e6sb4eu'},

      {id: 1, pos: 1, url: 'https://tinyurl.com/2mj4ybmz'},

      {id: 2, pos: 2, url: 'https://tinyurl.com/y75eb7sx'},

      {id: 3, pos: 3, url: 'https://tinyurl.com/363twa27'},

      {id: 4, pos: 4, url: 'https://tinyurl.com/3cksf5nf'},

    ]);


    function shuffle(item) {

      const heroPos = Math.floor(items.length/2);

      const hero = items.findIndex(({pos}) => pos === heroPos);

      const target = items.findIndex(({id}) => id === item.id);

      [items[target].pos,items[hero].pos] = [items[hero].pos,items[target].pos];

    }


    return {

      items,

      shuffle,

    }

  },

}).mount('#app');


 

³×ƼÁð ÀÇ°ß   ÀÌ¿ëÇϽŠÀÚ·áÀÇ Èı⸦ ÀÚÀ¯·Ó°Ô ÀÛ¼ºÇϼ¼¿ä. (»ó¾÷ÀûÀÎ ±¤°í ¹× µµ¹è¼º ±Û µîÀº »çÀüÅ뺸¾øÀÌ »èÁ¦µÉ ¼ö ÀÖ½À´Ï´Ù.)
³»¿ë ¾ÆÀ̵ð Àǰ߳²±â±â
µî·ÏµÈ ÀǰßÀÌ ¾ø½À´Ï´Ù.
1
À̸§
³»¿ë
:³×¸Â¾Æ¿ä: :È­³ª´Â±º¿ä: :Àá¿Í: :¿ì¿ïÇØ: :À̰ǾƳÄ: :¿ÕÇÏÇÏ: ¿Õ¿ôÀ½~ ³î·¥~
Æò°¡Çϱâ ÈǸ¢ÇÔ ¸Å¿ìÁÁÀ½ ÁÁÀ½ ±¦ÂúÀ½ º¸Åë º°·Î
µµ¹è¹æÁöŰ
 73638974 º¸ÀÌ´Â µµ¹è¹æÁö۸¦ ÀÔ·ÂÇϼ¼¿ä.