当前位置:网站首页>Vertical align cannot align the picture and text vertically
Vertical align cannot align the picture and text vertically
2022-07-27 08:23:00 【Gru 977】
problem :
Use vertical-align: middle; You can't center the picture and text vertically .
In this way HTML For example :
<div class="footer">
<div class="wrapper">
<div class="top">
<ul>
<li>
<!-- Add labels through pseudo elements , Implement the wizard diagram -->
<span> I'm Gru </span>
</li>
</ul>
</div>
</div>
</div>Solution steps :
1. Use vertical-align: middle; You can't center the picture and text vertically , The text is above .
/* Tags added by pseudo elements inline */
.footer .top li::before {
/* 1. Not centered */
vertical-align: middle;
}

2. Use line-height , At this time, the picture is lower .
.footer .top li {
/* 2. Add line height , Picture down */
line-height: 58px;
height: 58px;
}3. Try positioning , Let the picture and the text be at the same starting point , Then add margin-left Move back a distance .
.footer .top li {
position: relative;
}
/* Tags added by pseudo elements inline */
.footer .top li::before {
/* 3. Absolute positioning */
position: absolute;
top: 0;
left: 0;
}
.footer .top li span {
/* 3. Then adjust the position. */
margin-left: 77px;
}
summary :
Positioning may cause a chain reaction , So when adjusting , it is to be noted that , When is the parent , Which children are included under the parent , Wait a series ( At present, there is no in-depth discussion ).
边栏推荐
- DEMO:ST05 找文本ID 信息
- An ordinary autumn recruitment experience
- Luogu super Mary game
- Breadth first search
- Dirsearch[directory scanning tool]
- 如何卸载--奇安信安全终端管理系统
- The third letter to the little sister of the test | Oracle stored procedure knowledge sharing and test instructions
- Why do major domestic manufacturers regard cloud computing as a pastry? Do you really understand this trillion market
- Functions and arrow functions
- Record a PG master-slave setup and data synchronization performance test process
猜你喜欢
随机推荐
[netding cup 2020 Qinglong group]areuserialz (buuctf)
Database startup report error_ user_ connect_ times &gt; 0 error
Weekly learning summary
The code interface is a little automated
All in one 1329 cells (breadth first search)
All in one 1353 -- expression bracket matching (stack)
数据提取2
opengauss从库停掉,发现主库无法写入数据
ERP production operation control Huaxia
Bandwidth and currency
1176 questions of Olympiad in informatics -- who ranked K in the exam
1178 questions of Olympiad in informatics -- ranking of grades
It's better to be full than delicious; It's better to be drunk than drunk
Use of elastic box / expansion box (Flex)
Breadth first search
2020 International Machine Translation Competition: Volcano translation won five championships
Alibaba cloud international receipt message introduction and configuration process
[golang] golang develops wechat official account web page authorization function
Qt Creator代码风格插件Beautifier
Shell scripts related










