css - 如何在tailwindcss中将图像居中于另一个图像
问题描述
朋友们,我在将图像居中在另一个图像上并在顺风 css 中居中时遇到了问题。
<div className="w-1/6 h-11 relative text-center">
<span className="absolute left-0 right-0 w-full h-full">
<Image className="rounded-md" src="https://files.virgool.io/upload/users/785524/posts/sojszup8zfru/72bgkgkumdcq.jpeg" width="50" height="50" alt="video of" />
</span>
<span className="absolute">
<Image src="/svg/play.svg" alt="play video" width="25" height="25" />
</span>
</div>
我的结果是:
或者如果设置在播放图标的顶部和左侧
<span className="absolute left-1/2 top-1/2">
<Image src="/svg/play.svg" alt="podcast icon" width="25" height="25" />
</span>
图标在右下角
你看到播放图标在图像的左上角,我想在中间
谢谢您的帮助
解决方案
你可以试试这个类object-center
到 svg 图片
参考:https ://tailwindcss.com/docs/object-position
或将这些类添加到父 div flex-row content-center justify-center
推荐阅读
- opengl - 无法用鼠标选择在帧缓冲区中渲染的四边形
- python - 具有 **kwargs 输出的类:未定义 arg
- python - 我可以在识别段落中的给定单词时使用自然语言处理还是需要使用机器学习算法
- mysql - 如何计算查询结果
- php - Laravel:无法打开蒸汽:没有这样的文件或目录
- java - 我有错误:“javac.exe”以代码 3 退出
- excel - 如何在 vba 代码中捕获条件格式亮点
- javascript - React JSX 错误:标准 html 标签上的未封闭正则表达式(
- php - 如何在我的 while 循环之外获取每种产品的数量
- javascript - GraphQL 无法读取未定义的属性“查询”