[英]Github readme.md align images
I wish the two images on the readme file were vertically aligned, but I don't understand why on Github it is not succeeding.我希望自述文件中的两个图像垂直对齐,但我不明白为什么在 Github 上它没有成功。
How can I do it through markup languages?我怎样才能通过标记语言做到这一点?
Result:结果:
<div align="center"> <div style="display: flex;"> <img src="https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&layout=compact&show_icons=true&title_color=ffffff&icon_color=34abeb&text_color=daf7dc&bg_color=151515" style="vertical-align: top;" /> <img src="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&title_color=ffffff&icon_color=34abeb&text_color=daf7dc&bg_color=151515" /> </div> </div>
1. You can use a table (it has borders on github): 1.可以使用表格(在github上有边框):
<table> <tr> <td valign="top"><img src="https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&layout=compact&show_icons=true&title_color=ffffff&icon_color=34abeb&text_color=daf7dc&bg_color=151515"/></td> <td valign="top"><img src="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&title_color=ffffff&icon_color=34abeb&text_color=daf7dc&bg_color=151515"/></td> </tr> </table>
2. You can add align=top
to the img
tag: 2.可以在
img
标签中添加align=top
:
Note : It works as intended on github but not in the snippet注意:它在 github 上按预期工作,但不在片段中
<div> <img align=top src="https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&layout=compact&show_icons=true&title_color=ffffff&icon_color=34abeb&text_color=daf7dc&bg_color=151515"/> <img align=top src="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&title_color=ffffff&icon_color=34abeb&text_color=daf7dc&bg_color=151515"/> <div>
I've achieved this by adding height="200"
attribute in the img
tag.我通过在
img
标签中添加height="200"
属性来实现这一点。
But it has a caveat though.但它有一个警告。 GitHub won't let you remove the table border.
GitHub 不会让您删除表格边框。
<table cellpadding="0">
<tr style="padding: 0">
<!-- GitHub Stats Card -->
<td valign="top"><img height="200" src="https://github-readme-stats.vercel.app/api?username=snsakib&count_private=true&show_icons=true&theme=tokyonight&hide_border=true&custom_title=My%20GitHub%20Stats"/></td>
<!-- GitHub Top Language Card -->
<td valign="top"><img height="200" src="https://github-readme-stats.vercel.app/api/top-langs/?username=snsakib&langs_count=6&layout=compact&theme=tokyonight&hide_border=true&hide=HTML&custom_title=Top%20Languages"/></td>
</tr>
</table>
Let flexbox do the work for you.让 flexbox 为您完成工作。 No need for the alignment on the images themselves;
图像本身不需要 alignment; use
align-items: flex-start
on the container to align both images to the top.在容器上使用
align-items: flex-start
将两个图像对齐到顶部。
<div align="center"> <div style="display: flex; align-items: flex-start;"> <img src="https://github-readme-stats.vercel.app/api/top-langs/?username=anuraghazra&layout=compact&show_icons=true&title_color=ffffff&icon_color=34abeb&text_color=daf7dc&bg_color=151515"/> <img src="https://github-readme-stats.vercel.app/api?username=anuraghazra&show_icons=true&title_color=ffffff&icon_color=34abeb&text_color=daf7dc&bg_color=151515" /> </div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.