Excessive content overflowing in Bootstrap's card-body

I need help with fitting plotly figures into bootstrap cards in a card deck. The content within the card-body is flowing outside of the card width. I want to constrain the figures within the cards, as their height is defined but not width.

  <html>
        <head>
            <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a4c6cbcbd0d7d0d6c5d4e4908a918a97">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
            <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
            <style>
                .card {box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)}
                .row {margin-top: 30}
                .navbar {background-color: #0269AF}
            </style>
        </head>
        <body>
            <nav class="navbar navbar-dark #0269AF">
                <span class="navbar-brand mb-0 h1 abs" >Hypercare Trend Analysis: PNW & Florida</span>
            </nav>
            <div class="container-fluid">
                <div class="row">
                    <div class="col">
                        <div class="card-deck">
                            <div class="card">
                                <div class="card-header">
                                    Florida Hypercare Entries By Associate
                                    <br><i>Colors represent weeks since Go Live</i>
                                </div>
                                <div class="card-body">
                                   ''' + fig1 + '''
                                </div>
                            </div>
                            <div class="card">
                                <div class="card-header">
                                    PNW Hypercare Entries By Associate
                                    <br><i>Colors represent weeks since Go Live</i>
                                </div>
                                <div class="card-body">
                                   ''' + fig2 + '''
                                </div>
                            </div>
                            <div class="card">
                                <div class="card-header">
                                    Florida Hypercare Entries By Associate
                                    <br><i>Colors represent weeks since Go Live</i>
                                </div>
                                <div class="card-body">
                                   ''' + fig3 + '''
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </body>
    </html>

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

Example figure:

<div> 
... (content shortened for brevity) ...
       </div>
                                </div>

Answer №1

When adjusting the image CSS, ensure the following properties are set:

img {
max-width: 100%;
max-height: 100%;
}

img {
    max-width: 100%;
    max-height: 100%;
}


#1196883d-1e8e-41df-b08d-1f4390672660 {
border :solid;
}

svg {
max-width: 70%;
    max-height: 80%;

}
<html>
        <head>
            <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c9aba6a6bdbabdbba8b989fde7fce7fa">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
            <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
            <style>
                .card {box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)}
                .row {margin-top: 30}
                .navbar {background-color: #0269AF}
            </style>
        </head>
        <body>
            <nav class="navbar navbar-dark #0269AF">
                <span class="navbar-brand mb-0 h1 abs" >Hypercare Trend Analysis: PNW & Florida</span>
            </nav>
            <div class="container-fluid">
                <div class="row">
                    <div class="col">
                        <div class="card-deck">
                            <div class="card">
                                <div class="card-header">
                                    Florida Hypercare Entries By Associate
                                    <br><i>Colors represent weeks since Go Live</i>
                                </div>
                                <div class="card-body">
                                                    <div>                            <div id="1196883d-1e8e-41df-b08d-1f4390672660" class="plotly-graph-div" style="height:405px; width:100%;"></div>            <script type="text/javascript">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById("1196883d-1e8e-41df-b08d-1f4390672660")) {                    Plotly.newPlot(                        "1196883d-1e8e-41df-b08d-1f4390672660",                        [{"alignmentgroup": "True", "bingroup": "y", "hovertemplate": "Weeks Grouping=0 - 12 Weeks<br>count=%{x}<br>Employee=%{y}<extra></extra>", "legendgroup": "0 - 12 Weeks", "marker": {"color": "#636efa"}, "name": "0 - 12 Weeks", "offsetgroup": "0 - 12 Weeks", "orientation": "h", "showlegend": true, "type": "histogram", "xaxis": "x", "y": ["Sherry Scheffer"], "yaxis": "y"}],                        {"barmode": "relative", "font": {"size": 8}, "height": 405, "legend": {"title": {"text": "Weeks Grouping"}, "tracegroupgap": 0}, "margin": {"b": 0, "l": 0, "r": 0, "t": 0}, "template": {"data": {"bar": [{"error_x": {"color": "#2a3f5f"}, "error_y": {"color": "#2a3f5f"}, "marker": {"line": {"color": "#E5ECF6", "width": 0.5}}, "type": "bar"}], "barpolar": [{"marker": {"line": {"color": "#E5ECF6", "width": 0.5}}, "type": "barpolar"}], "carpet": [{"aaxis": {"endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f"}, "baxis": {"endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f"}, "type": "carpet"}], "choropleth": [{"colorbar": {"outlinewidth": 0, "ticks": ""}, "type": "choropleth"}], "contour": [{"colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale":...

Answer №2

Upon observation, it appears that this issue is resolved when the page is resized. One workaround is to simulate a page resize by including the following script:

<script type="text/javascript">
window.dispatchEvent(new Event('resize'));
</script>

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

Utilizing jQuery to Execute a Function Upon Addition or Removal of Class Names

Currently, I am working on a function that includes a conditional statement to display an alert when a specific class name is removed from a div layer. Below is the code snippet: <div class="ui-tabs-panel ui-tabs-hide">panel</div> <div>& ...

Can you explain the purpose of using "link href="#""?

While browsing through the source code of a website, I came across this interesting snippet. <link href="#" id="colour-scheme" rel="stylesheet"> I'm curious, what exactly does this code snippet do? ...

Limit the maximum column gap on the grid and stop it from expanding further

I'm currently facing an issue with some columns/rows on my website that are keeping content locked in the top left corner, reminiscent of early 00's web design. The site was originally designed for smaller screens like 1024x764, so when viewed on ...

How to use CSS to create two columns that adjust in height based on the content within

I am working with bootstrap columns and looking to ensure that the two columns, col-md-4 and col-md-8, have an equal height regardless of their content. The content in col-md-4 will vary, so I need a solution for them to maintain the same height. <div ...

Including Previous & Next Buttons in Product Categories

I have set up the display of category products on the home page using the block below: {{block type="catalog/product_list" template="catalog/product/home_short.phtml" category_id="5" column_count="6"}}. I now want to include previous and next buttons to ...

Leveraging jQuery's .animate method to create engaging search box animations

Greetings esteemed individuals... I am currently working on enhancing the search component for my application... http://jsfiddle.net/SkyKOG/K8utq/24/ input{ display:none; width:0px; color:#999; } Initially, I only had a simple search box so ...

When working on a node.js project with Angular, I'm considering incorporating a new HTML framework such as Foundation Zurb or Bootstrap. Is this a good idea, or should I stick

Is it necessary to use an additional HTML framework like Foundation Zurb or Bootstrap when using Angular in a node.js project? Can Angular alone handle the functionalities provided by Foundation Zurb / Bootstrap? Your insights would be greatly appreciated ...

Creating a vertically scaling div with full height using Bootstrap 3

I am facing an issue with creating a full-height website using Twitter because the body min-height set to 100% seems to be causing problems. Here is my CSS code: html{ height:100%; } body{ min-height:100% } #main{ min-height:100%; } And here ...

Learn how to make a contenteditable div perform tab spacing with a simple keystroke of the tab key

I've been trying to figure out how to make this contenteditable div add tab spacing when I press the tab key, but so far no luck. If anyone has a solution for this issue, please feel free to share. You can use an ID, class, or any other method to get ...

A webpage featuring a 2-column layout with a footer, along with a right column that is absolutely positioned and

I'm currently working on a basic two-column layout: <div class = "parent"> <div class = "left-column"> </div> <div class = "right-column"> </div> </div> <div class = "footer"></div> The con ...

The div background image in Vue.js is displaying a 404 not found error

I've encountered an issue while trying to set a background for a div. Strangely, when using the same relative path with an img tag everything works fine, but as soon as I try to achieve the same result with a div, I receive a 404 error. This img tag ...

The jQuery UI slider is behaving strangely when rotated

Looking to create a jQuery UI Slider that operates in a 90-degree rotation. I attempted rotating and sliding, but it didn't produce the desired result. Oddly enough, when dragging horizontally, the slider moves vertically. Take a look at this interact ...

SEO problem with meta refresh and form field click interruption

I have a webpage that automatically refreshes every 30 seconds with new random content. I am currently using a meta tag to achieve this, but I recently read an article stating that meta refresh is not SEO friendly. Can you suggest a more SEO-friendly metho ...

Scroll automatically when dragging the mouse

My D3 tree creation is causing an issue with the horizontal scroll bar in Firefox 37. When trying to drag select a tree node, the horizontal scroll bar does not work. However, in Chrome, the horizontal scroll works fine during drag selection. <div cl ...

Angular 4 incorporating a customized Bootstrap 4 accordion menu for seamless navigation

I am trying to implement a nested menu using a JSON object in Angular 4. Below is the code I have written. <div id="panel-group"> <div class="panel panel-default" *ngFor="let mainItem of objectKeys(my_menu); let i = index"> <div class ...

Steps to create a navbar that spans only 75% of the header

Hello, I am currently working on a project and I am trying to deploy a navbar that looks like this: I have tried multiple CSS scenarios but I can't seem to achieve it. I explored everything in the Bootstrap documentation but couldn't find a solu ...

Position images on the right side of text within the container

I'm having trouble aligning the Facebook and Google+ icons on my website, which can be found here. These circular icons are located just below the navigation bar at the top of the page. The navigation bar is part of a class called 'container_head ...

What are the recommended web-safe colors to use for styling an <hr> element?

Having an <hr> element with the color #ac8900 is what I require. When I apply the style in the traditional way <hr color="#ac8900"> it functions perfectly. However, the expectation is to style everything using CSS, so I attempted the followin ...

Additional room on the right-hand side

I've been working on my website, www.ribbonhill.co.uk, and I'm facing an issue with a white space on the right side that only appears on mobile phones. Interestingly, this problem doesn't show up in full mode on Chrome and Edge browsers. Ho ...

Using CSS to leverage the power of both Grid and Flex simultaneously

Help Needed: CSS Challenge! I'm not a fan of CSS and can't seem to crack this code conundrum. Here's what I want the end result to look like: https://i.sstatic.net/z06qO.png Current Situation: #newOrderControl { border-style: solid ...