next.js 边框悬停周围的材质UI

z9ju0rcb  于 2022-11-05  发布在  其他
关注(0)|答案(1)|浏览(137)

我希望它当文本字段是悬停,然后文本字段周围的一个边界。我不能设置边界hove。我是新的材料UI。请任何人帮助我?如何解决它?这是我的所有代码。

import React from 'react';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import { styled } from '@mui/material/styles';

const Shipping = () => {
  const Border = styled(Box)(() => ({
    padding: '2',
    marginTop: '60px',
    select: {
        borderColor: 'red',
    },
  }));

  return (
    <Box>
      <Typography variant="h5">Shipping Information</Typography>

      <Border>
        <Typography variant="caption" display="block">
          Caeleb Dressel
        </Typography>
        <Typography variant="caption" display="block" marginTop="24px">
          +14097575013
        </Typography>
        <Typography variant="caption" display="block" marginTop="24px">
          caelebdressel@example.com
        </Typography>
        <Typography variant="caption" display="block" marginTop="24px">
          417 Wahignton Ave. Green cove Springg, Plorida 39495
        </Typography>
      </Border>
    </Box>
  );
};

export default Shipping;
68de4m5k

68de4m5k1#

您可以像这样在悬停时显示边框:

const Border = styled(Box)(() => ({
    padding: "2",
    marginTop: "60px",
    border: "1px solid white",
    "&:hover": {
      borderColor: "red"
    }
  }));

您可以查看this sandbox,了解此解决方案的一个实际示例。

相关问题