[1]: https://i.stack.imgur.com/HRYwR.png
#header {
font-family: "NotoNashkArabic", "ProximaNova-regular", "Helvetica Neue", "Helvetica", Roboto, Arial, sans-serif;
margin: 0;
background-color: #2E7061;
margin-left: auto;
margin-right: auto;
width: 100%;
height: 80px;
}
#title {
color: white;
text-align: center;
padding:10px 5px 20px 5px;
margin-right: 20px;
margin: -.1px;
font-size: 1.7em;
border-right: 1px solid white;
}
html
<body>
<div id="header">
<img src="Capture1.png"/>
<p id="title">THE Text</p>
</div>
</body>
答案 0 :(得分:0)
你可以把它添加到你的css #title
display: inline-block;
将是,
#title {
display: inline-block;
color: white;
text-align: center;
padding:10px 5px 20px 5px;
margin-right: 20px;
margin: -.1px;
font-size: 1.7em;
border-right: 1px solid white;
我希望它能解决你的问题
答案 1 :(得分:0)
您提供的代码不足以重现您在图片中显示的内容。但我会假设你的图像暂时浮动。
#header {
font-family: "NotoNashkArabic", "ProximaNova-regular", "Helvetica Neue", "Helvetica", Roboto, Arial, sans-serif;
margin: 0;
background-color: #2E7061;
margin-left: auto;
margin-right: auto;
width: 100%;
height: 80px;
}
#header img{
float: left;
}
#title {
color: white;
text-align: right;
padding-right: 20px;
margin-right: 20px;
margin: -.1px;
font-size: 1.7em;
border-right: 1px solid white;
width: 50%;
margin-left: 200px;
height: 100%;
line-height:80px;
}
<body>
<div id="header">
<img src="http://placehold.it/200x80.png">
<p id="title">THE Text</p>
</div>
</body>
我在这里做的是:
width: 50%
上设置#title
。 (任意值)margin-right: 20px; // This has no meaning...
margin: -.1px; // ...since it gets overridden by this.