将内容对齐到一个Bootstrap行的下方,其中上面的列具有偏移。

huangapple go评论77阅读模式
英文:

align content underneath a boostrap row where the above columns have an offset

问题

我有一排需要 offset-md-1 的锚点/ div,我的问题是下面的内容需要与上面带有偏移的一排对齐,并且要具有响应性。我似乎无法弄清楚如何做到这一点。当我在段落上使用边距时,当视口缩小时,内容会溢出。我也无法使用边距自动设置最大宽度,因为上面的行设计上不是完全“居中”的。有什么建议吗?谢谢 将内容对齐到一个Bootstrap行的下方,其中上面的列具有偏移。

HTML:

<div class="container">
  <div class="row">
    <a class="offset-md-1 col-md-3 jump-link" href="#">
      <div><p class="font__jump-link">跳转链接1 偏移1</p></div>
    </a>
    <a class="col-md-3 jump-link" href="#">
      <div><p class="font__jump-link">跳转链接2</p></div>
    </a>
    <a class="col-md-3 jump-link" href="#">
      <div><p class="font__jump-link">跳转链接3</p></div>
    </a>
  </div>
  <div class="row">
    <p class="p-below-links">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab assumenda at commodi dicta, doloremque earum eius libero neque repudiandae soluta.</p>
  </div>
</div>

CSS:

.p-below-links {
  max-width: 1050px;
  width: 100%;
}

注意:以上是您提供的代码的翻译部分。

英文:

I have a row of anchors / divs that require an offset-md-1, my issue is the content below the row of anchors needs to align with the row above that has the offset and be responsive. I cannot seem to figure out how to do this. When I use margins on the paragraphs the content overflows when viewport shrinks. I also cannot set a max width with margins auto as the row above is not exactly "center" by design. Any ideas? thank you 将内容对齐到一个Bootstrap行的下方,其中上面的列具有偏移。

html:

      &lt;div class=&quot;container&quot;&gt;
        &lt;div class=&quot;row&quot;&gt;
          &lt;a class=&quot;offset-md-1 col-md-3 jump-link&quot; href=&quot;#&quot;&gt;
            &lt;div&gt;&lt;p class=&quot;font__jump-link&quot;&gt;Jump Link 1 offset1&lt;/p&gt;&lt;/div&gt;
          &lt;/a&gt;
          &lt;a class=&quot;col-md-3 jump-link&quot; href=&quot;#&quot;&gt;
            &lt;div&gt;&lt;p class=&quot;font__jump-link&quot;&gt;Jump Link 2&lt;/p&gt;&lt;/div&gt;
          &lt;/a&gt;
          &lt;a class=&quot;col-md-3 jump-link&quot; href=&quot;#&quot;&gt;
            &lt;div&gt;&lt;p class=&quot;font__jump-link&quot;&gt;Jump Link 3&lt;/p&gt;&lt;/div&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class=&quot;row&quot;&gt;
          &lt;p class=&quot;p-below-links&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab assumenda at 
            commodi dicta, doloremque
            earum eius libero neque repudiandae soluta.&lt;/p&gt;
        &lt;/div&gt;
      &lt;/div&gt;

css:

.p-below-links{
 max-width:1050px
 width: 100%;

答案1

得分: 1

为什么不能简单地应用相同的偏移量?一般来说,Bootstrap 网站中的所有内容都应该由网格包含,以确保一致的行为。

<div class="container">
  <div class="row">
    <a class="col-3 offset-xs-1 jump-link" href="#">
      <div>
        <p class="font__jump-link">跳转链接1 偏移1</p>
      </div>
    </a>

    <a class="col-3 jump-link" href="#">
      <div>
        <p class="font__jump-link">跳转链接2</p>
      </div>
    </a>

    <a class="col-3 jump-link" href="#">
      <div>
        <p class="font__jump-link">跳转链接3</p>
      </div>
    </a>
  </div>

  <div class="row">
    <div class="col-9 offset-xs-1">
      <p class="p-below-links">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab assumenda at commodi dicta, doloremque earum eius libero neque repudiandae soluta.</p>
    </div>
  </div>
</div>

示例演示

英文:

Why can't you just apply the same offset? Generally speaking, all content in a Bootstrap site should be contained by the grid for consistent behavior.

&lt;div class=&quot;container&quot;&gt;
  &lt;div class=&quot;row&quot;&gt;
    &lt;a class=&quot;col-3 offset-xs-1 jump-link&quot; href=&quot;#&quot;&gt;
      &lt;div&gt;
        &lt;p class=&quot;font__jump-link&quot;&gt;Jump Link 1 offset1&lt;/p&gt;
      &lt;/div&gt;
    &lt;/a&gt;

    &lt;a class=&quot;col-3 jump-link&quot; href=&quot;#&quot;&gt;
      &lt;div&gt;
        &lt;p class=&quot;font__jump-link&quot;&gt;Jump Link 2&lt;/p&gt;
      &lt;/div&gt;
    &lt;/a&gt;

    &lt;a class=&quot;col-3 jump-link&quot; href=&quot;#&quot;&gt;
      &lt;div&gt;
        &lt;p class=&quot;font__jump-link&quot;&gt;Jump Link 3&lt;/p&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;/div&gt;

  &lt;div class=&quot;row&quot;&gt;
    &lt;div class=&quot;col-9 offset-xs-1&quot;&gt;
      &lt;p class=&quot;p-below-links&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab assumenda at commodi dicta, doloremque earum eius libero neque repudiandae soluta.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

Fiddle demo

huangapple
  • 本文由 发表于 2020年1月7日 01:23:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616383.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定