What is the best way to display the counter result on the cards at the top of an html webpage?

My latest project involves a comparison script using Groovyscript to analyze two distinct files. Embedded within the Groovyscript is HTML code that utilizes CSS and potentially Bootstrap of any version.

I have successfully implemented counters with a title at the top of my HTML page, but unfortunately, they are not dynamic or responsive. Adjusting the width and height of the page causes layout issues. I've heard that Bootstrap/CSS can assist in reorganizing the page when the resolution changes. Thus, I decided to use cards. While this improved the situation, the layout still gets distorted when resizing the page.

    <html lang='en'>
        <head>
        <!-- Required meta tags -->
        <meta charset='utf-8'>
        <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
        <!-- Bootstrap CSS -->
        <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css' integrity='sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ' crossorigin='anonymous'>
        <title>GroovyCardsBootstrap</title>    
        <style>   
        h{color:#86BEB6; font-size:50px;}
        * {box-sizing: border-box;}
        body {font-family: Arial,Helvetica, sans-serif;}
        .row {margin: 0 -3px;}
        .row:after {
            content: '';display: table;clear: both;
            }
        .card {
            display:inline-block;
            box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
            padding: 16px;
            text-align: center;
            }
        .card-group [class*='col-']{
            float:none;}
        </style>
        </head>
        <body>
        <div class='card-group'>
            <div class='card'>
                <div class='card-block'>
                    <img class='card-text'  src='FODBosa.png'  alt='FodBosa.png' width='400' height='150' />
                </div>
            </div>
            <div class='card' style='flex-grow: 3'>
                <div class='card-block'>
                    <span class='card-text' style='padding:0 5px'>Text 2</span><span class='card-text' style='padding:0 5px'>More text 2</span><span class='card-text' style='padding:0 5px'>More text 2</span>
                    
                </div>
            </div>
        </div>
        <h>Test results comparison KBO with PDC</h>
        <div style = 'border:1px solid black; border-collapse: collapse;'>
            <p>Automated tests are executed in ReadyAPI. These are the results of the comparison on the responses between KBO and PDC</p>
        </div>"
After running the Groovyscript, here are the final lines of code:

outputFile.append "<div class='card-group'><div class='card' style='background-color:black; color:white;'><div class='card-block'> <h3>Not found in KBO</h3> <p>" +notInPDCCounter+ "</p></div></div>"
    outputFile.append "<div class='card-group'><div class='card' style='background-color:#DA4747;'><div class='card-block'> <h3>Failed - PDC not same as KBO</h3>  <p>" +hasDifferences+ "</p></div> </div>"
    outputFile.append "<div class='card-group'><div class='card' style='background-color:#ff8080;'><div class='card-block'> <h3>Total lines read</h3>    <p>"+ failed + "</p></div></div>"
    outputFile.append "<div class='card-group'><div class='card' style='background-color:#52DA69;'><div class='card-block'> <h3>Passed - Info is in PDC</h3>    <p>" +(totalTotal-failed)+ "</p></div> </div> </div>"

The organized boxes generated by outputFile.append appear below the opening paragraph on the HTML page (due to including the code for visibility). My goal is to display these results inside the cards created initially (located next to <img>). How can I integrate the dynamically generated counter results from the Groovy script into the right card at the top? Any advice would be greatly appreciated.

https://i.sstatic.net/36xrV.png

Answer №1

Trying to figure out if this is the correct approach:

Are you attempting to showcase 4 cards in a row at the top right corner of the page? Additionally, are you looking for these cards to adjust responsively based on different viewport widths?

While I may not have experience with Groovy, one potential solution could involve wrapping your cards in a div (or selecting the div through an ID) and utilizing CSS Grid for responsiveness. By creating a 4-column grid layout, you can define the width of each column so that they stack into a new row as the viewport size decreases.

I hope this suggestion proves helpful!

Answer №2

Thanks to a helpful tip from Erika Ravazollo, I was able to figure it out:

To make it work, I inserted this JQuery script at the bottom of the page (inside the body tags):

outputFile.append "<script> \$('#source').appendTo('#destination');</script>"

It seems that for Groovyscript, you have to omit the dollar sign with a backslash. The reason why is unclear to me. When defining my cards at the top, I placed the destination like so:

        <div class='card' style='flex-grow: 3' id='destination'></div>

I also removed the span tags.

For the source cards, I added them in this manner:

<div class='card-block' id='source'>....</div>

I made some adjustments to the layout as well. In the example I provided, there are nested boxes within boxes – it's kind of a fun challenge! :-)

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

How to disable an anchor tag based on a condition using ng-class?

I have a displayed table that includes a column called count which has an <a> tag with a href to a page. I want to show a link for all rows where count > 0 and disable it when count=0. I attempted to use AngularJS - ng-disabled not working for An ...

Creating a WordPress Infographic: How to Design a "Wide" Graphic

I have a question for those who are experienced with infographics. I'm in the process of getting an infographic designed for my blog and I've noticed that some websites have a feature that allows the infographic to expand to full width when you c ...

Uploading large files on Vuejs causes the browser to crash

Whenever I try to upload a file using my browser (Chrome), everything goes smoothly for files with a size of 30mb. However, if I attempt to upload a file that is 150mb in size, the browser crashes. The server's maximum upload size has been configured ...

Exploring the World of Audio Playback with R Shiny

For this question, I am incorporating the following libraries: library("shiny") library("tuneR") library("markdown") Although, it seems that only shiny is relevant in this context. According to the Shiny tag glossary, I should be able to utilize tags$a ...

"Troubleshooting a matter of spacing in HTML5 body

I've been struggling to eliminate the gap between the top of my webpage and the <div> element. Here's the code snippet causing the issue: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="v ...

Tips for transferring data when clicking in Angular 5 from the parent component to the child component

I need assistance with passing data from a parent component to a child component in Angular 5. I want the child component to render as a separate page instead of within the parent's template. For example, let's say my child component is called & ...

Exploring ReactJS: Combining JSON data with HTML elements

Recently, I started learning ReactJS. As I'm iterating through JSON data, I realized I need to incorporate some links into it. This is how my JSON data is structured: "text": ["For more information on the functionalities of the platform and services ...

Ways to Design ASP.NET Buttons for Users with Disabilities

Recently, I attempted to style an asp button using CSS. The Button HTML: <asp:Button ID="btnClockin" runat="server" Text="Clock In" class="FullWidthButton" /> Here is the CSS code: .FullWidthButton {width:100%;} Everything was working fine until ...

Using CSS to overlay text on an image on a webpage

Can anyone help me with this puzzling scenario? <TD><a href="index-1.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image20','','images/m21.jpg',1)">Home</a><img src="images/m2.jpg" nam ...

Interior CSS border

Check out my progress so far: jsfiddle.net/warpoluido/JkDhN/175/ I'm attempting to adjust the height of the green section to be slightly higher than the blue (or similar color) one, as shown in the image. The design needs to remain responsive. < ...

Aligning text in a vertical progress bar using absolute positioning

Currently, I am trying to create a health bar-like element but I am facing difficulties in centering the text within it. Despite exhausting all my options, the text is either off-center when its length changes or extends beyond the borders of the bar. Her ...

Guide to verifying a value within a JSON object in Ionic 2

Is there a way to check the value of "no_cover" in thumbnail[0] and replace it with asset/sss.jpg in order to display on the listpage? I have attempted to include <img src="{{item.LINKS.thumbnail[0]}}"> in Listpage.html, but it only shows the thumbna ...

PHP persistent forms dropdowns and checkbox selection

I am currently working on a PHP form and I am facing an issue with the drop-down boxes and checkboxes. I want them to stay filled even if I don't select something, maintaining the previously entered details while leaving the unfilled parts empty. I ha ...

Positioning the video tag bar in HTML is a crucial element to

**Take a look at what I'm discussing here(http://jsfiddle.net/VpLyR/). I'm dealing with a simple code that includes a video tag (html) and a menu bar with a fixed position. The issue arises when I scroll down to the point where both the menu bar ...

Control the transparency of the initial parent div that includes an *ngFor loop

I want to add opacity only to the first div which contains an icon and a heading in another nested div. The second div should remain fully visible (opacity: 1). Here is the HTML structure: <div class="row clearfix"> <div class="col-lg-3 col- ...

Unable to update navigation link color in Bootstrap 4 styling

<nav id="section_navbar" class="navbar navbar-expand-lg fixed-top"> <div class="mx-auto my-2 order-0 order-md-1 position-relative"> <div id="top_logo" class="container-fluid"> <span>VirtualQR</ ...

The dragging and dropping feature for HTML input type="file" is not functioning properly in Edge and IE11

I've developed an Angular app using this sample where I have included only an input control on the screen. Within my project, I constructed a custom file-uploader component. While I am able to drag and drop files in Chrome, I encountered issues with d ...

What's the best way to expand the right side of .li following a left offset of -20px

My nested list structure looks like this... https://i.sstatic.net/sggVx.png What you see is a recursive ul/li setup... <div class="family d-block"> <span class="pb-2"> <small class="text-muted">Family:</small><br> < ...

Creating a dynamic quiz with random images using text boxes in HTML and PHP

I am working on creating a 'guess the picture' style quiz where a random image is displayed as the question, and users must input their answer in a textbox. The question will be selected randomly from 3-5 options each time the page is refreshed o ...

Retrieving checkbox value upon form submission

Imagine having a form containing several checkboxes. Upon submitting the form, you aim to display all values of the selected checkboxes. <form> <input type="checkbox" id="product1" name="product1" value="12"> <input type="checkbox" id="prod ...