html - 如何在 HTML 中创建“复杂”标题?
问题描述
我想在 HTML 中创建一个标题,但我犯了一些错误,无法弄清楚我是如何以正确的方式做到这一点的。
这就是我尝试这样做的方式:
.xyz-logo {
float:left;
width:472px;
}
.headerlayout h1{
position:center;
font-family: Arial, Helvetica, sans-serif ;
font-size: x-large;
width:1920px;
height:200px;
background:lightgrey;
}
<div class="headerlayout">
<img class="xyz-logo" src="C:\Users\..." alt="Logo">
<h1 >This is the title</h1>
</div>
这是它的外观图片:
解决方案
正如 Paul 所提到的,您可以使用 Flexbox 或 Grid 来解决它,但是如果您想要一些简单的东西可以玩,这里有一个使用绝对定位的解决方案。只需更改顶部、左侧和底部的值即可更改其位置。标题中的变换总是居中。
.headerlayout{
position: relative;
width: 100%;
background-color: lightgrey;
height: 200px;
}
.xyz-logo {
position: absolute;
top: 0;
left: 0;
}
.headerlayout h1{
font-family: Arial, Helvetica, sans-serif;
font-size: 35px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -100%);
}
.something{
position:absolute;
bottom:0%;
left:0%;
}
<div class="headerlayout">
<img class="xyz-logo" src="C:\Users\..." alt="Logo">
<h1>This is the title</h1>
<div class="something">Something that changes</div>
</div >
推荐阅读
- python - 在计时子进程调用时在有限循环中运行 timeit 会导致无限循环卡在第一个循环参数上
- python - SQL INSERT ERROR -117:值的数量不等于列的数量
- javascript - 为视频网站创建第一次 chrome 扩展以删除广告(使用按 ID 获取元素来删除类)
- string - LUA 脚本,有人可以帮忙吗?有条件的
- regex - 正则表达式 - 移动验证
- visual-studio-code - 如何在 Nrwl - Fullstack Nest+angular 应用程序中使用 watch 配置 VS 代码调试器?
- java - java 7 for 循环到 java 8 IntStream forEach
- python - 为什么我的矩形不绘制?- python和pygame
- python - 如何从文本文件中删除特定行?
- c# - 具有派生参数的递归重载方法