div 上的 HTML 边框位于具有边框样式的 div 外部

标签 html css

我目前遇到以下问题,我不想使用 Samples 这个词包裹在边框中,我想用 <hr 表示 sample (周围没有边框)在它下面,然后是它下面有一个边框的 div 列表。我不确定为什么 Samples 在这里被包围,因为它在我的带边框的 div 之外。请注意,我确定没有其他带边框的 div 包装此 html。下面的屏幕截图和 HTML:

HTML:

<div class="col-md-12" style="margin-top: 75px">
        <h3 class="pull-left" style="font-size: 45px">Samples</h3>
    </div>
    <div class="col-md-12">
        <hr>
    </div>

    <div ng-controller="SamplesQueryController">
        <div style="border: 1px solid #000000">
            <div ng-repeat="item in data" style="margin-left: 14px">
                <a href="#/sample/{{item.id}}"
                    style="font-size: 34px; text-decoration: underline">{{item.name}}</a>
                <br> <span style="font-size: 20px">{{item.description}}</span><br>
                <hr>
            </div>
        </div>
    </div>

最佳答案

行为来自 Bootstrap 风格。 为避免这种情况,将每一行包装在 class="row" div

html {padding:2em; /*demo*/}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
  <div class="col-md-12" style="margin-top: 75px">
    <h3 class="pull-left" style="font-size: 45px">Samples</h3>
  </div>
  <div class="col-md-12">
    <hr>
  </div>
</div>
<div class="row">
  <div ng-controller="SamplesQueryController">
    <div style="border: 1px solid #000000">
      <div ng-repeat="item in data" style="margin-left: 14px">
        <a href="#/sample/{{item.id}}" style="font-size: 34px; text-decoration: underline">{{item.name}}</a>
        <br> <span style="font-size: 20px">{{item.description}}</span><br>
        <hr>
      </div>
    </div>
  </div>
</div>


你的 html :

    html {padding:2em; /*demo*/}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-md-12" style="margin-top: 75px">
        <h3 class="pull-left" style="font-size: 45px">Samples</h3>
    </div>
    <div class="col-md-12">
        <hr>
    </div>
    <div ng-controller="SamplesQueryController">
        <div style="border: 1px solid #000000">
            <div ng-repeat="item in data" style="margin-left: 14px">
                <a href="#/sample/{{item.id}}"
                    style="font-size: 34px; text-decoration: underline">{{item.name}}</a>
                <br> <span style="font-size: 20px">{{item.description}}</span><br>
                <hr>
            </div>
        </div>
    </div>

关于div 上的 HTML 边框位于具有边框样式的 div 外部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35927179/

相关文章:

CSS动画速度控制

html - "loading"导航到下一页时图像挂起

jquery 下拉选择值

html - 显示剪切的标题文本

css - 将自定义 CSS 添加到我的 Polylang 小部件并删除元素符号 - 使用 WordPress

css - Angularjs v1.3.15 - 页面加载时 Webkit 文本颜色渲染错误

C# Web浏览器点击Javascript按钮

html - 可以在 Div 边框上有投影吗?

javascript - 将 <div> 叠加在另一个(动态定位的)<div> 上

html - 导航位于底部,需要内部列表显示在导航上方而不是导航下方吗?