margin-bottom:100px不工作

时间:2016-10-13 12:50:49

标签: html html5 css3 html5-canvas

我正在尝试使用我的样式标签中的css .up将图像的右侧放在div标签的底部,但我发现没有运气,为了得到iamge.Can任何帮助我怎么能得到右边图像到底部使用边距

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Bootstrap Case</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
    div.round1 {
      border: 1px solid deepskyblue;
      border-radius: 4px;
      height: 170px;
      width: 30%;
      margin: auto;
    }
    .up {
      margin-bottom: 350;
    }
  </style>
</head>

<body>

  <div class="round1">

    <table>
      <tr>
        <td>
          <img src="https://placeholdit.imgix.net/~text?txtsize=12&txt=128%C3%97128&w=128&h=128" alt="Mountain1" style="width:128px;height:128px;">
          <br>If a browser cannot find an image, it will display the alternate text
        </td>

        <td>
          <img class="up" src="https://placeholdit.imgix.net/~text?txtsize=15&txt=138%C3%9770&w=138&h=70" style="width:138px;height:70px;">
        </td>
      </tr>

    </table>
  </div>

  <br>
  <div align="left">
    <div class="container">
      <ul class="nav nav-tabs">
        <li class="active"><a data-toggle="tab" href="#home">One</a>
        </li>
        <li><a data-toggle="tab" href="#menu1">Two</a>
        </li>
        <li><a data-toggle="tab" href="#menu1">Functional</a>
        </li>
        <li><a data-toggle="tab" href="#menu3">Three</a>
        </li>
      </ul>

      <div class="tab-content">
        <div id="home" class="tab-pane fade in active">
          <h3>One</h3>
          <p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text.</p>
        </div>
        <div id="menu1" class="tab-pane fade">
          <h3>Two</h3>
          <p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
        </div>
        <div id="menu2" class="tab-pane fade">
          <h3>Three</h3>
          <p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
        </div>
        <div id="menu3" class="tab-pane fade">
          <h3>Others</h3>
          <p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
        </div>
      </div>
    </div>
  </div>
</body>

</html>

2 个答案:

答案 0 :(得分:1)

你忘了使用px 将您的代码更改为:

.up {
    margin-bottom:350**px**;
}

答案 1 :(得分:0)

您可以提供td vertical-align:bottom,无论大小不同,都可以确保正确的图片始终贴在底部

拥有动态解决方案总是更好

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Bootstrap Case</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <style>
    div.round1 {
      border: 1px solid deepskyblue;
      border-radius: 4px;
      height: 170px;
      width: 30%;
      margin: auto;
    }
    td{ /*add this*/
       vertical-align:bottom;
     }
    .up {
      /*margin-bottom: 350; -- don't use both*/
    }
  </style>
</head>

<body>

  <div class="round1">

    <table>
      <tr>
        <td>
          <img src="https://placeholdit.imgix.net/~text?txtsize=12&txt=128%C3%97128&w=128&h=128" alt="Mountain1" style="width:128px;height:128px;">
          <br>If a browser cannot find an image, it will display the alternate text
        </td>

        <td>
          <img class="up" src="https://placeholdit.imgix.net/~text?txtsize=15&txt=138%C3%9770&w=138&h=70" style="width:138px;height:70px;">
        </td>
      </tr>

    </table>
  </div>

  <br>
  <div align="left">
    <div class="container">
      <ul class="nav nav-tabs">
        <li class="active"><a data-toggle="tab" href="#home">One</a>
        </li>
        <li><a data-toggle="tab" href="#menu1">Two</a>
        </li>
        <li><a data-toggle="tab" href="#menu1">Functional</a>
        </li>
        <li><a data-toggle="tab" href="#menu3">Three</a>
        </li>
      </ul>

      <div class="tab-content">
        <div id="home" class="tab-pane fade in active">
          <h3>One</h3>
          <p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text.</p>
        </div>
        <div id="menu1" class="tab-pane fade">
          <h3>Two</h3>
          <p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
        </div>
        <div id="menu2" class="tab-pane fade">
          <h3>Three</h3>
          <p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
        </div>
        <div id="menu3" class="tab-pane fade">
          <h3>Others</h3>
          <p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
        </div>
      </div>
    </div>
  </div>
</body>

</html>