当前位置:网站首页>Line height equals height why not center
Line height equals height why not center
2022-06-13 03:49:00 【_ Virgo programmer's daily life】
Be careful :height It must be the height of the content box , That is to say box-sizing:content-box Under the circumstances , if border-box when , At this time height Is the height of the whole box , Need to subtract padding,border、margin Is the size of the real content box height.
Like a box box-sizing:border-box,border:10px,height:40px, The height of the content box should be 20px,line-height Set to 20px You can achieve the upper and lower center .
notes :box-sizing The default value of the property is :content-box , But in the actual development, we often May be written as :box-sizing: content-box.
So let's write one box-sizing:border-box Example :
<style>
div{
width: 200px;
height: 00px;
border: 20px solid red;
background-color: red;
height: 100px;
line-height: 100px;
box-sizing: border-box;
}
</style>
<div> study hard </div>
It is obvious that the text is not centered vertically 
When we change to box-sizing: content-box when ;
边栏推荐
- Lambda终结操作reduce归并
- Lambda end operation reduce merge
- 单片机:A/D 差分输入信号
- Oracle built-in functions
- Wechat payment configuration
- 【测试开发】自动化测试selenium篇(一)
- No more! Another member of the team left..
- Lambda end operation find and match findany
- How much can I get after the insurance period of annuity insurance products expires?
- Synching build your own synchronization cloud
猜你喜欢
随机推荐
Spark Optimization -- differences and policy selection of RDD cache (cache, persist, checkpoint)
单片机:A/D 差分输入信号
EGO planner论文翻译
Explain usage, field explanations, and optimization instances of MySQL
Meaning of different values of margin and padding
Summary of meeting between president Ren and scientists and experts in system engineering
Serialization & deserialization
What to bring to 2022
Lambda终结操作max&min
【多线程】多线程到底是个甚——多线程初阶(复习自用)
Field * doesn't have a default value problem
ROS中的msg消息
缓存读写--写
Among the four common technologies for UAV obstacle avoidance, why does Dajiang prefer binocular vision
任总与系统工程领域科学家、专家会谈纪要
【面试复习】自用不定时更新
Lambda终结操作查找与匹配allMatch
单片机:EEPROM 多字节读写操作时序
Lambda终结操作count
Lambda termination operation Max & min









