CSS 中段落和标题的对齐方式

用户5447339

我有一个下面的设计,我试图在 HTML 和 CSS 中复制它:

在此处输入图片说明

注:我写的文字Margin,并Padding让一切变得简单易懂。它不会出现在实际设计中

在这一刻,我能够在我的小提琴中得到这个

唯一与小提琴中的上述设计不匹配的东西are the paragraphs (eg: Our main goal, Among our biggest, etc) in every box which don't have line break我正在考虑将方框作为每个职位空缺的标题(后端 ..、前端 .. 等)和段落(例如:我们的主要目标、我们最大的目标等)。

每个框的 CSS 是:

.firstrow {
    display: inline-block;
    width: 100%;
}


.firstrow #front-end {
    text-align: center;
    width: 50%;
    height: 250px;
    float: left;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    background-size: 100% 100%;
    justify-content: center;
}
双鱼座

这是您的代码的改进版本,仅使用 flexbox,不使用floats 或其他任何东西。

h2 {
  text-align: center;
  font-size: 2.8rem;
  color: #444444;
}

.row {
  display: flex;
  flex-wrap: wrap;
  padding: 5%;
}

.row>div {
  padding: 5%;
  background: gray;
  margin: 15px;
  display: flex;
  flex-flow: column wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  box-sizing:border-box
}
<div class="job-openings">
  <h2>Seems Interesting? Apply Now</h2>
  <div class="row">
    <div id="back-end">
      <h3>Back-end Developer</h3>
      <p> Our main goal is to build and maintain the online platform and...</p>
    </div>
    <div id="front-end">
      <h3>Front-end Web Developer</h3>
      <p>Among our biggest priorities are interface design and user experience...</p>
    </div>
    <div id="graphics">
      <h3>Graphics Designer</h3>
      <p> We believe in the power of design. Our designers are motivated, creative and...</p>
    </div>
    <div id="sales">
      <h3>Sales &amp; Marketing</h3>
      <p>Our Marketing team is focussed on driving growth and building a brand that customers love...</p>
    </div>
  </div>
</div>

Op的评论回答:

后端和前端将排在一行,图形设计师以及销售和营销将排在另一排。

假设您希望始终有 2 行,那么您可以使用flex:0 50%代替flex:1,在这种情况下flex: 0 calc(50% - 30px)计算边距

h2 {
  text-align: center;
  font-size: 2.8rem;
  color: #444444;
}

.row {
  display: flex;
  flex-wrap: wrap;
  padding: 5%;
}

.row>div {
  padding: 5%;
  background: gray;
  margin: 15px;
  display: flex;
  flex-flow: column wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 0 calc(50% - 30px);
  box-sizing:border-box
}
<div class="job-openings">
  <h2>Seems Interesting? Apply Now</h2>
  <div class="row">
    <div id="back-end">
      <h3>Back-end Developer</h3>
      <p> Our main goal is to build and maintain the online platform and...</p>
    </div>
    <div id="front-end">
      <h3>Front-end Web Developer</h3>
      <p>Among our biggest priorities are interface design and user experience...</p>
    </div>
    <div id="graphics">
      <h3>Graphics Designer</h3>
      <p> We believe in the power of design. Our designers are motivated, creative and...</p>
    </div>
    <div id="sales">
      <h3>Sales &amp; Marketing</h3>
      <p>Our Marketing team is focussed on driving growth and building a brand that customers love...</p>
    </div>
  </div>
</div>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

CSS:图片和标题的对齐问题

来自分类Dev

CSS和标签输入对齐方式与表格

来自分类Dev

CSS和Struts 2形式的对齐方式

来自分类Dev

CSS修复Button和图片的对齐方式

来自分类Dev

CSS:如何减少div中段落的边距?

来自分类Dev

在CSS中对齐跨度,段落和锚点

来自分类Dev

Bootstrap / CSS:卡主体中的单独标题和段落

来自分类Dev

如何在CSS中内联显示标题和段落元素?

来自分类Dev

CSS:响应式Div的边距和对齐方式?

来自分类Dev

CSS:位置和对齐方式之间存在冲突

来自分类Dev

CSS:响应式Div的边距和对齐方式?

来自分类Dev

Firefox和Chrome之间的CSS图像对齐方式差异

来自分类Dev

CSS文本和图像对齐方式,以%为单位

来自分类Dev

在 HTML 和 CSS 中,图像左对齐,文本和标题右对齐

来自分类Dev

CSS将UL与标题对齐

来自分类Dev

将标题/标题与文本 HTML、CSS 对齐

来自分类Dev

CSS 对齐和大小

来自分类Dev

模式框的段落文本未使用 css 和 asp.net 居中对齐

来自分类Dev

在CSS中将按钮行与标题对齐

来自分类Dev

在CSS响应网格上对齐长标题

来自分类Dev

对齐中心CSS和After CSS

来自分类Dev

如何使用 CSS 和 HTML 对齐导航标题中的文本?

来自分类Dev

分隔和对齐标题和段落元素的最佳方法

来自分类Dev

UIButton标题和图像的对齐方式不同

来自分类Dev

对齐文字和图标CSS

来自分类Dev

对齐文字和图标CSS

来自分类Dev

CSS浮动对齐方式不下降

来自分类Dev

CSS垂直图像对齐方式的变化

来自分类Dev

css <ul> <li>:项目的对齐方式