html - 如果我设置边距,图像会被覆盖

标签 html css

使用此 html 代码:

<div class="container-fluid" >
        <div class="row">
            <div class="col-md-3" >
              <table id="Table" width="100%">
                    <tr>
                        <td    align="left" valign="middle" >
                            <img src="MyImage" width="220" height="200">
                        </td>
                    </tr>



                    <tr>
                        <td width="251" height="400" align="left" valign="top" >

                            <p style="margin-top: 20px; margin-bottom: 0px;">
                                <img src="MyImage2" width="220" height="200">
                            </p>                           
                        </td>
                    </tr>
                </table> 
            </div>

            <div class="col-md-9 "  >

            <form id="form1" class="form-horizontal" runat="server" >
                      <div " align="left" >
                Some other HTML stuff
                          </div>
            </form>
          </div>

        </div>
    </div>

它工作正常,但是,我需要在 MyImage2 之前添加 50px 的左边距。 所以我以这种方式更新我的代码。

<div class="container-fluid" >
        <div class="row">
            <div class="col-md-3" >
              <table id="Table" width="100%">
                    <tr>
                        <td    align="left" valign="middle" >
                            <img src="MyImage" width="220" height="200">
                        </td>
                    </tr>



                    <tr>
                        <td width="251" height="400" align="left" valign="top" style="margin-left: 50px;">
<!-----------------50 px margin added------------->
                            <p style="margin-top: 20px; margin-bottom: 0px;margin-left: 50px;">
                                <img src="MyImage2" width="220" height="200">
                            </p>                           
                        </td>
                    </tr>
                </table> 
            </div>

            <div class="col-md-9 "  >

            <form id="form1" class="form-horizontal" runat="server" >
                      <div " align="left" >
                Some other HTML stuff
                          </div>
            </form>
          </div>

        </div>
    </div>

对于这段代码,我遇到了响应问题。 如果我减小窗口大小,右框架上显示的“其他 HTML 内容”将覆盖 50 像素的 image2。

如何让正确的框架不覆盖图像 2 的正确部分?

我试图增加 td 和/或表格标签的宽度,但它对我不起作用。所以希望有人可以帮助我。

编辑: 您可以在此链接上检查问题: http://www.bootply.com/t1hF1cHuD2 缩小窗口,使右框架覆盖左框架(这是我不想发生的事情)

最佳答案

尽量不要使用内联样式,因为有时它会导致问题,我建议在标题中制作一个部分并尝试放置 margin-left:50px !important;看看是否有效。你也可以使用 position:relative;并使用左上右下属性将其移动到您想要的位置。

关于html - 如果我设置边距,图像会被覆盖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40934308/

相关文章:

css - 自定义插件不会加载我的 CSS

html - 容器中的一行是否需要 span12? Bootstrap

jquery - 当我将鼠标悬停在 img 上时创建带有文本的叠加层

javascript - 是否可以在 CSS 中使用三元运算符?

php - 如何使用 php html 中的 href 标签将 php 中的值发布到另一页面

jQuery fadein() fadeout() 问题,暂时将 div 向下推直到完全淡出

html - CSS 表单设计帮助

html - 如何让 2 个相邻 block 不显示 :inline-block?

html - 单独的 css 引用中的多个类样式

javascript - 在 CSS 计数器样式类中添加前导零