html - 带有标题元素的内联徽标
问题描述
HTML 代码:
<div class="header">
<img src=".jpg" width="240" height="180" >
<h1>MY APPS</h1>
<p>TRY AND ERROR, CODING IS FUN</p>
</div>
CSS:
.header{
background-color: rgb(255,255,255,0.7);
}
.header img {
float: left;
width: 100px;
height: 100px;
background: #555;
}
.header h1 {
position: relative;
top: 18px;
left: 50%;
padding: 12.5px
}
.header p {
position: relative;
top: -25px;
left: 50%;
padding: 12.5px
}
我怎样才能把我<img>
的内联<h1>
?
解决方案
试试这个代码
.header{
display:flex;
align-items:center;
justify-content:center;
}
.header img {
width: 100px;
height: 100px;
background: #555;
margin-right: 20px;
}
.header-content h1 {
margin-top: 0px;
}
.header-content p {
margin-bottom: 0px;
}
<div class="header">
<img src=".jpg" width="240" height="180" >
<div class="header-content">
<h1>MY APPS</h1>
<p>TRY AND ERROR, CODING IS FUN</p>
</div>
</div>
推荐阅读
- spring-boot - 类型与 KFunction1 不匹配
> - sql-server - 当条件为“缺少数据”时,如何创建条件类型的 JOIN 或 WHERE 子句?
- android - 如何在 didChangeAppLifecycleState(iOS 和 android 设备)上完全重启颤振应用程序
- angular - Angular 页面在服务器端渲染后加载两次
- apache-spark - coalesce(1).limt(100000) 的性能
- node.js - 我在邮递员中发送了一些 json 数组数据,但似乎错误
- ios - “可以转换为 Swift 5” 无法转换代码
- python - 如何检查电子邮件结尾的正确性?
- knex.js - 如何使用 knexjs 计算表格中的所有空单元格?
- c - 如何使用 c 找到 DFS 中的组件数量?