html - 如何在 div 中水平对齐 Logo 和 h1

标签 html css asp.net position alignment

我想在 div 的左端对齐一个 Logo ,并在该 div 的中心对齐一个文本(文本应该看起来像在屏幕中心)。 div 的宽度适合屏幕。 Logo 和文本应在同一行。它是如何成为可能的?我已经像下面这样开始了。但是逐行显示了两个元素。

<div >
<img id="imglogo" alt="" src="images/ logo.JPG"  style="width: 300px;height:75px"  />
<h1 align="center" id="H1">Project Name</h1>
</div>

最佳答案

就个人而言,我更喜欢 table ,因为它可以很好地放置东西并且可靠。见下文:

<table border=1 style="table-layout: fixed; width:100%">
  <tr>
    <td><img id="imglogo" alt="" src="https://placehold.it/100x35" /></td>
    <td style="text-align: center">Centered Text</td>
    <td></td>
  </tr>
</table>

当然,您可以根据需要进行自定义。

关于html - 如何在 div 中水平对齐 Logo 和 h1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42618710/

相关文章:

html - 表格右上角的 CSS 位置图标

javascript - 在下拉单击时更改 iFrame

html - HTML 的<cite>、<em> 和<i> 标签有什么区别?

c# - 如何将 Crystal 报表绑定(bind)到手动创建的DataSet

javascript - 通过循环数组设置 setAttribute 的值

html - Flex 元素忽略 Firefox 中的填充百分比

html - 重复的按钮列表

css 垂直对齐溢出标题

c# - 在 aspx 网页上使用 JsonObject 的内容

c# - 将SQL字符串查询改为参数化查询;使用C#调用数据库类文件的语法