跳到主要内容

前端 margin 对比

· 阅读需 1 分钟
ahKevinXy

尺寸

margin top



function MarginTop(props) {
let arrList = [

]
for (let i =0;i <100;i ++){
arrList = [...arrList,{
marginTop: {
marginTop: i+'px',
padding:0
},
i :i
}]
}
const concatPx = (item)=>{

return 'margin top '+item +'px'
}
const [listSize,setListSize] = useState([])
useEffect(() => {
for (let i=10;i <100;i ++){
setListSize(...listSize,i)
}


}, [])
return <div style={{cursor:'pointer'}}>

{
arrList.map(item=>{
return <div key={item.i} style={item.marginTop} title={concatPx(item.i)} ><sup>{concatPx(item.i)} </sup></div>
})
}
</div>
}


margin right



function MarginRight(props) {
let arrList = [

]
for (let i =0;i <100;i ++){
arrList = [...arrList,{
marginTop: {
marginRight: i+'px',
padding:0
},
i :i
}]
}
const concatPx = (item)=>{

return 'margin right '+item +'px'
}
const [listSize,setListSize] = useState([])
useEffect(() => {
for (let i=10;i <100;i ++){
setListSize(...listSize,i)
}


}, [])
return <div style={{cursor:'pointer'}}>

{
arrList.map(item=>{
return <span key={item.i} style={item.marginTop} title={concatPx(item.i)} ></span>
})
}
</div>
}


Loading Comments...