[英]How to vertically align a div with text
I've been stuck on this problem for a while.我已经被这个问题困住了一段时间。 To better explain the question that I'm asking here is a picture: Picture
为了更好地解释我在这里问的问题,有一张图片:图片
Hopefully that helps a bit.希望这会有所帮助。 Here is my code:
这是我的代码:
.Home { background-color: white; padding: 35px 60px; }
<p style="text-align: right; background-color: #e9e9e9;font-family:arial;font-size:20px;">upper message</p> <div style="text-align:center;background-color:black;"> <img src="/Images/logo-text.png" width="250" hight="240" align="left"> <button class="Home">Home</button> </div>
So what I'm trying to do is have the div align with the text vertically.所以我想要做的是让 div 与文本垂直对齐。 Thanks in advance!
提前致谢!
Use devtools to troubleshoot.使用 devtools 进行故障排除。 If you focus on your
<p>
element you'll see that it has 20px margin.如果您专注于
<p>
元素,您会看到它有 20 像素的边距。
.Home { background-color: white; padding: 35px 60px; } p { margin: 0; }
<p style="text-align: right; background-color: #e9e9e9;font-family:arial;font-size:20px;">upper message</p> <div style="text-align:center;background-color:black;"> <img src="/Images/logo-text.png" width="250" hight="240" align="left"> <button class="Home">Home</button> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.