Picture featuring Bootstrap's column/div layout being broken

I'm encountering some challenges with integrating TinyMCE and Bootstrap into a CMS I built.

On a particular page, there's a div outlined where users can select images from a modal by clicking on it. The selected image is then inserted into a TinyMCE instance, saved in HTML format to the database, and also displayed within the div for preview.

I'm seeking assistance to ensure that even if the user adds a large image via TinyMCE, it remains contained within the bootstrap column without breaking the layout.

The empty div:

https://i.sstatic.net/Nj3AY.png and after adding a large image

https://i.sstatic.net/QE5w3.png

Is there a specific element or attribute I can incorporate in the HTML code to prevent any oversized images placed in TinyMCE from disrupting the div layout?

<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%;
    }

   (Remaining CSS styles omitted for brevity)

  </style>

  (External stylesheet links and JavaScript libraries excluded for clarity)

</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 clickable div 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 clickable div to select an image -->
        </div>
      </div>
    </div>
  </div>
</body>

</html>

Answer №1

If you want to set the width to 100%, simply use width: 100%. You can leave the height as auto or omit it altogether to maintain the aspect ratio.

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/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4e29272429210e7f60776078">[email protected]</a>/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/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1a5b4a5b9b4a391e0ffe3ffe5">[email protected]</a>/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/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee8987848981aedfc0d7c0d8">[email protected]</a>/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>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is it possible to change the inner html to null during an active ajax request?

My goal is to have two separate data.html files inserted into two different HTML files without needing a click event. I want the structure of my data.html files to remain consistent, while allowing the template of my website to change dynamically by callin ...

React Material-UI eliminates the 'content' property from the CSS pseudo-element

Creating a React MUI Box and styling it like this: <Box id='my-box' sx={{ '&::before': { content: 'Yay! ', backgroundColor: 'red' } }} >Life is beautiful</Box> However, duri ...

What could be the reason why the @media print selector is not showing the correct format when I try to print?

When I click the print button, the text is supposed to display in four columns in the print dialog, but it appears as paragraphs instead. This is my script code where there is a click event for the print button. When I click on it, the print dialog pop ...

Modifying the HTML file won't be immediately visible in browsers

I encountered a frustrating issue while working on my website. Despite making changes to the code, the browsers are not reflecting the updates. This problem is occurring in Internet Explorer, Google Chrome, and Firefox. Initially, I had a div with a link ...

Guide on inserting quotation marks into the src value of the image tag

I recently came across several posts in a database that had similar structures like these: <a href="somelink.html"><img src=someimage.jpg border=1 alt="some text"></a> To fix this issue, I need to: Remove the border=1 attribute (I pla ...

Automatically populate login credentials on a webpage using Javascript scripting

Can anyone provide insights on why the input credentials on a webpage cannot be autofilled with this code? Is there a solution to make it functional? Trying to automate login process using JavaScript: function Test() { var name = document.getElementBy ...

Webpack for customized white label sass/css styling

My goal is to produce multiple CSS files using webpack for a customizable application. I aim to execute the webpack CSS/SASS loaders once for each unique 'brand' and have it saved into individual files. This approach is necessary because I maint ...

No data appearing in the div elements

I have retrieved data from the database and I am attempting to display it inside a nested div structure. However, the data is not showing up in the intended div. Here is the problem I am trying to display the message You said: Hello 2hrs alongside the use ...

When attempting to reload a single page application that utilizes AJAX, a 404 error is encountered

Recently, I've been working on coding my personal website and have successfully created a single page application using ajax. The content is dynamically loaded between the header and footer whenever a navigation bar link is clicked. To enable the back ...

Tips for displaying two div elements side by side on the same line

Two div elements are structured like this: <div class="pdetails"> <div class="contact_details"> text </div> <div class="clear"></div> <div id="contact_area_form_" class="tform_wrapper"> text ...

What method can I use to enlarge the carousel component from the flowbit-svelte library?

I have been working on a project that requires a Carousel, and I decided to incorporate the flowbit-svelte carousel into my svelte project. While the carousel is functioning well, I am facing an issue with the component size. It seems to be cutting off my ...

What exactly is the function of $fix-mqs within the IE Sass mixins created by Jake Archibald?

I'm really struggling to understand the purpose behind using $fix-mqs in the mentioned link: Although I can grasp how the rest of the mixin functions, this particular part has me stumped. In a project where I've utilized this pattern, everything ...

What is the best way to ensure the image fills the entire space available?

Creating a website and looking to incorporate an image in the header section. Here is the HTML code: <header class="jumbotron"> <div class="container"> <div class="row row-header"> <div class="col-x ...

Experiencing overflow due to Bootstrap form styling

Issue: While working on creating a signup form, I've encountered a problem where the screen has a slight overflow on the right side whenever there are form groups included in the form. Steps taken so far: I have utilized Chromium dev tools to identi ...

Peeling back the layers of a particular element

This is my code snippet: <pre id='code'> <ol> <li class='L1'><span>hello</span></li> <li class='L2'><span>Hi</span></li> <li class='L3&apos ...

Steps for incorporating MailChimp API into a Bootstrap contact form

I followed a tutorial on Bootstrapious to create a contact form using the Bootstrap framework. However, since I have no experience with PHP, I am struggling to integrate a MailChimp API with validation. I came across another tutorial for MailChimp API in ...

Problem with spacing in a Bootstrap 5 column of size medium-5

I'm currently working on a template for my website and facing an issue with removing the margin displayed on the right side of my div using flex. I've tried setting the margin to 0 on one of the columns and also experimented with changing the col ...

Can CSS be used to create curved dashed lines?

Is it possible to achieve dashed lines similar to the ones highlighted in the images below using only CSS? I have a responsive web page built with Bootstrap, and I need the dashed lines to adjust accordingly when the window width changes. https://i.sstat ...

Tips for keeping a div stationary when an adjacent div expands

I am facing an issue with 3 blocks in a row - a large block, a smaller block that can expand, and a third block placed under the first block. When the smaller block expands, the top of the third block moves to match the bottom of the expanding div. However ...

Creating an HTML table that automatically generates sub rows dynamically

Looking to provide users with the ability to construct a table where they can create expressions. For example, in the expression shown below (((c1 A/O c2) A/O C3) A/O C4), where A/O represents 'And' and 'Or' conditions selected by the u ...