html - 如何水平对齐内容

标签 html css alignment block

我是新来的,所以提前为这个问题道歉......

我正在尝试创建 3 个文本 block ,但将它们水平对齐。我不想创建按钮,只想创建文本 block 。

这个 HTML 似乎不起作用

<div id="boxes">
    <h1>EFFICIENT</h1>
    <p>Each part of the budget is spent programmatically with a performance objective</p>

    <h1>TAILORED</h1>
    <p> Each campaign is different and tailored to our clients needs</p>

    <h1>DEDICATED</h1>
    <p>Our team is fully dedicated to our client with a personalised approach and daily contacts</p>
</div>

和 CSS

#boxes {
  height: 300px;
  width: 100%;
  position: relative;
  padding-top: 50px;
  padding-bottom: 100px;
   }

#boxes h1 p {
float: left;
  }

最佳答案

试试这个:

      #boxes {
		  height: 90px;
		  border: 2px dotted #ee944d;
		  display: table-cell;
		  vertical-align: middle;
          padding:15px;
		}
		
	#boxes h1 p {
			float: left;
			text-align:left;
		}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>

<body>
	  <div id="boxes">
		<h1>EFFICIENT</h1>
		<p>Each part of the budget is spent programmatically with a performance objective</p>

		<h1>TAILORED</h1>
		<p> Each campaign is different and tailored to our clients needs</p>

		<h1>DEDICATED</h1>
		<p>Our team is fully dedicated to our client with a personalised approach and daily contacts</p>
	  </div>
</body>
</html>

关于html - 如何水平对齐内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45522394/

相关文章:

java - BoxLayout 忽略子面板对齐

css - 在全屏页面上仅垂直对齐 2 个元素

javascript - 2 列布局,直到第一个列高度完成,然后是一列布局

java - 是否可以在 JAVAFX 上创建带有锁定 y 轴的水平滚动折线图?

javascript - 缩放固定宽度的字体以适应一行中恒定数量的字符

html - CSS 计数器增量不起作用

css - 如何使文本与 block 居中但左对齐?

java - java if 语句帮助

jquery - Bootstrap 导航栏下拉菜单部分隐藏在 IE8 中 - 为什么?

html - 如何在 Chrome 中调整纯 flexbox masonry 网格,它已经在 Firefox 中运行