问题描述
出于个人培训目的,我正在尝试复制Google主页。我已经尽力了,但是我在侧边栏上很挣扎(仅在移动屏幕上可用)。
问题是img
标签中有一个text
+ <a>
SVG,并且文本未居中于SVG的中间。
我尝试了margin auto
,vertical-align
,css grid
,flexbox
,line-height
,但没有找到解决方法。
我知道这是有可能的,因为Google做到了,但是我不知道如何做到。
(您可以在这里查看我的工作以及实际的问题:https://cocothepimp.github.io/Google-Landing-page/public/或下面的代码段)
#sidebar {
height: 150px;
width: 250px;
background-color: #cfcfcf;
padding-top: 15px;
}
#sidebar>div {
background-color: red;
height: 48px;
}
#sidebar>div>a {
background-color: pink;
line-height: 20px; // important to keep
margin: auto 0;
}
#sidebar>div>a>img {
background-color: whitesmoke;
margin: 12px;
}
<div id="sidebar">
<div>
<a href="#">
<img src="https://www.gstatic.com/navigationdrawer/privacy_advisor_icon.svg">
Comment fonctionne la recherche Google ?
</a>
</div>
</div>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)