<div class="container">
<div class="header">
<img class="logo" src="https://mdn.mozillademos.org/files/6457/mdn_logo_only_color.png"/>
<span class="text">Title Here</span>
</div>
</div>
我试图将“标题”放在中间,然后将徽标放在徽标的左侧。
标题名称将是动态的,因此无论长度如何,标题名称始终应居中
答案 0 :(得分:1)
更改CSS
.container{
padding: 15px 15px 20px 15px;
height: 247px;
width: 780px;
border-radius: 5px;
margin-bottom: 30px;
background-color: #2D343D;
}
.logo {
width: 55px;
float:left;
vertical-align:middle;
}
.header {
height: 56px;
color: #FFFFFF;
margin-top: 15px;
font-size: 29.98px;
letter-spacing: 0.43px;
line-height: 40px;
text-align:center;
position: relative;
}
答案 1 :(得分:1)
尝试
.container{
padding: 15px 15px 20px 15px;
height: 247px;
width: 780px;
border-radius: 5px;
margin-bottom: 30px;
background-color: #2D343D;
}
.logo {
width: 55px;
vertical-align:middle;
}
.header {
height: 56px;
color: #FFFFFF;
margin-top: 15px;
font-size: 29.98px;
letter-spacing: 0.43px;
line-height: 40px;
text-align: center;
position: relative;
}
答案 2 :(得分:0)
这就是你想要的样子吗?
package com.web.servlets;
.container {
padding: 15px 15px 20px 15px;
height: 247px;
width: 780px;
border-radius: 5px;
margin-bottom: 30px;
background-color: #2D343D;
position: relative;
}
.logo {
width: 55px;
vertical-align: bottom;
}
.header {
height: 56px;
color: #FFFFFF;
margin-top: 15px;
font-size: 29.98px;
letter-spacing: 0.43px;
line-height: 40px;
text-align: center;
position: absolute;
top: 50%;
left:50%;
transform: translate(-50%,-50%);
}