带有引导程序的图像,中断列/ div

时间:2018-09-13 19:46:36

标签: html css bootstrap-4 tinymce

我已经建立了CMS,使用TinyMCE和Bootstrap时遇到了一些问题。

我有一个页面,其中概述了div,如果用户单击div,则可以从模式中选择图像。图像被插入到tinymce实例中,并且当用户单击“保存”时,将使用html(来自tinymce)将其保存到数据库中,但也将其添加到div中进行预览。

我需要帮助找到一种方法来确保无论图像多大,它始终包含在引导列中。

空div:

enter image description here 然后添加大图像

enter image description here

即使在tinyMce中放置了巨大的图像,我也可以在html中使用某些内容来确保引导不会中断div吗?

<html>

<head>
  <title>Template One</title>

  <style type="text/css">
    @import "style.css";
    html,
    body {
      height: 100%;
      overflow: hidden;
    }
    
    .modal-lg {
      max-width: 80% !important;
    }
    
    .my-container {
      display: flex;
      flex-direction: column;
      height: 100%;
    }
    
    .my-container>.top [class^="col-"],
    .my-container>.bottom [class^="col-"] {
      background-color: #929292;
      color: white;
      text-align: center;
    }
    
    .my-container>.middle {
      flex-grow: 1;
      padding: 30px;
      background-size: cover;
    }
    
    .my-container>.middle>* {}
    
    #clock {
      /*background-color:#333;*/
      font-family: sans-serif;
      font-size: 40px;
      text-shadow: 0px 0px 1px #fff;
      color: #fff;
    }
    
    #clock span {
      color: #fff;
      font-size: 40px;
      position: relative;
    }
    
    #date {
      margin-top: -10px;
      letter-spacing: 3px;
      font-size: 20px;
      font-family: arial, sans-serif;
      color: #fff;
    }
    
    .buttonContainer {
      display: flex;
      flex-direction: column;
      justify-content: center;
    }
  </style>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" crossorigin="anonymous">
  <link href="https://cdn.jsdelivr.net/npm/gijgo@1.9.6/css/gijgo.min.css" rel="stylesheet" type="text/css" />
  <link href="https://rawgit.com/tempusdominus/bootstrap-4/master/build/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link href="src/ytv.css" type="text/css" rel="stylesheet" />

  <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
  <script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.0/moment-with-locales.js"></script>
  <script src="https://rawgit.com/tempusdominus/bootstrap-4/master/build/js/tempusdominus-bootstrap-4.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gijgo@1.9.6/js/gijgo.min.js" type="text/javascript"></script>
  <script type='text/javascript' src='//cdn.jsdelivr.net/jquery.marquee/1.4.0/jquery.marquee.min.js'></script>


</head>

<body>

  <div class="container-fluid my-container">
    <div class="row middle">
      <div class="col-lg-6 leftFifty" id="leftFifty">
        <div class="leftContent" style="background-color: white; height: 100%; border: dotted 1px black;">
          <!-- This is the div that is clicked in to select an image -->
        </div>
      </div>
      <div class="col-lg-6 rightFifty" id="rightFifty">
        <div class="rightContent" style="background-color: white; height: 100%; border: dotted 1px black; ">
          <!-- This is the div that is clicked in to select an image -->
        </div>
      </div>
    </div>
  </div>
</body>

</html>

1 个答案:

答案 0 :(得分:1)

真正要做的就是设置width: 100%;高度可以auto,也可以完全省略以保持宽高比。

img {
  width: 100%;
  height: auto;
}
<html>

<head>
  <title>Template One</title>

  <style type="text/css">
    @import "style.css";
    html,
    body {
      height: 100%;
      overflow: hidden;
    }
    
    .modal-lg {
      max-width: 80% !important;
    }
    
    .my-container {
      display: flex;
      flex-direction: column;
      height: 100%;
    }
    
    .my-container>.top [class^="col-"],
    .my-container>.bottom [class^="col-"] {
      background-color: #929292;
      color: white;
      text-align: center;
    }
    
    .my-container>.middle {
      flex-grow: 1;
      padding: 30px;
      background-size: cover;
    }
    
    .my-container>.middle>* {}
    
    #clock {
      /*background-color:#333;*/
      font-family: sans-serif;
      font-size: 40px;
      text-shadow: 0px 0px 1px #fff;
      color: #fff;
    }
    
    #clock span {
      color: #fff;
      font-size: 40px;
      position: relative;
    }
    
    #date {
      margin-top: -10px;
      letter-spacing: 3px;
      font-size: 20px;
      font-family: arial, sans-serif;
      color: #fff;
    }
    
    .buttonContainer {
      display: flex;
      flex-direction: column;
      justify-content: center;
    }
  </style>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.css" crossorigin="anonymous">
  <link href="https://cdn.jsdelivr.net/npm/gijgo@1.9.6/css/gijgo.min.css" rel="stylesheet" type="text/css" />
  <link href="https://rawgit.com/tempusdominus/bootstrap-4/master/build/css/tempusdominus-bootstrap-4.min.css" rel="stylesheet" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link href="src/ytv.css" type="text/css" rel="stylesheet" />

  <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
  <script src="https://npmcdn.com/tether@1.2.4/dist/js/tether.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.0/moment-with-locales.js"></script>
  <script src="https://rawgit.com/tempusdominus/bootstrap-4/master/build/js/tempusdominus-bootstrap-4.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/gijgo@1.9.6/js/gijgo.min.js" type="text/javascript"></script>
  <script type='text/javascript' src='//cdn.jsdelivr.net/jquery.marquee/1.4.0/jquery.marquee.min.js'></script>


</head>

<body>

  <div class="container-fluid my-container">
    <div class="row middle">
      <div class="col-lg-6 leftFifty" id="leftFifty">
        <div class="leftContent" style="background-color: white; height: 100%; border: dotted 1px black;">
          <img src="https://via.placeholder.com/600x250" />
          <!-- This is the div that is clicked in to select an image -->
        </div>
      </div>
      <div class="col-lg-6 rightFifty" id="rightFifty">
        <div class="rightContent" style="background-color: white; height: 100%; border: dotted 1px black; ">
          <!-- This is the div that is clicked in to select an image -->
        </div>
      </div>
    </div>
  </div>
</body>

</html>