[英]How can I align the image and the h1 header ajadecently?
I have problems with trying to align the image and the h1 tag together on one line. 我试图将图像和h1标签对齐在一条线上时遇到问题。 I tried display: inline and inline-block they didn't work and only made the container of the two. 我试过显示:内联和内联块它们不起作用,只制作了两个容器。 I added the width to 100% on the section and still nothing. 我在该部分添加了100%的宽度,但仍然没有。 Float doesn't work either and if it did, it screws up the alignment of the page. Float也不起作用,如果确实如此,它会搞砸页面的对齐方式。 What am I doing wrong? 我究竟做错了什么? Sometimes it's hard to understand why it doesn't work as intended and need some help. 有时很难理解为什么它不能按预期工作并需要一些帮助。
HTML HTML
<section>
<img id="me" src="assets/img/pose1.jpg" alt="A photo of me." />
<h1>FOLLOW ME ON...</h1>
</section>
CSS CSS
section{
display:inline-block;
width:100%;
}
h1{
position:relative; /*position wherever desired on the page*/
top:0;
bottom:0;
right:0;
left:0;
font-weight:bold;
font-size:40px;
color:#FFFFFF;
background-color:#FFB405;
}
Try this:- 试试这个:-
h1{
position:relative; /*position wherever desired on the page*/
top:0;
bottom:0;
right:0;
left:0;
font-weight:bold;
font-size:40px;
color:#FFFFFF;
background-color:#FFB405;
display: inline-block;
}
You have some CSS conflicts on h1
... 你在h1
上有一些CSS冲突......
This should work 这应该工作
section {
display: block;
}
h1 {
position:relative; /*position wherever desired on the page*/
display: inline-block;
font-weight:bold;
font-size:40px;
color:#FFFFFF;
background-color:#FFB405;
}
section img {
display: inline-block;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.