Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

random picture position in react

import React, { useRef } from 'react';
    
const Image = () => {
   const ChipStyles = useRef({
       position: 'absolute',
       top: Math.floor(Math.random()*50),
       left: '50%',
       transform: 'translate(-50%, -50%)'
   });

   return (
     <img src={myImg} style={ChipStyles.current} alt=""}/>
   )
}
    
export default Image
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #random #picture #position #react
ADD COMMENT
Topic
Name
6+3 =