Adjust image to fit inside a compact popup window - Implementing React.js and Bootstrap

Hello, I could really use some help with a problem I'm facing. I am currently working on my personal portfolio website using react.js and bootstrap. I've integrated the react popupbox package, but I noticed that on small screens, my picture is not centered when the popup opens. Is there a way to adjust this using CSS?

This is the code snippet for declaring the popupbox:

    const Portfolio = () => {
    const openPopupboxFlappyBird = () => {
    const content = (
        <>
            <img className="portfolio-image-popupbox" src= {flappyBird} alt="Flappy Bird" />
            <p>Flappy Bird game written in C#</p>
            <a className="hyper-link" onClick={() => window.open("https://github.com/zacikmareek/simpleFlappyBird", "_blank")}>Github link</a>
        </>
    )
  PopupboxManager.open({ content })
}    

    const popupboxConfigFlappyBird = {
      titleBar: {
        enable: true,
        text: "Flappy Bird"
      },
      fadeIn: true,
      fadeInSpeed: 500
    }

Here is how the image is added:

return (
        <div className="portfolio-wrapper">
            <div className="container">
                <h1 className="text-lovercase text-center py-5">.portfolio()</h1>
                <div className="image-box-wrapper row justify-content-center">
                    <div className="portfolio-image-box" onClick={openPopupboxFlappyBird}>
                        <img className="portfolio-image" src={flappyBird} alt="Flappy Bird" />
                        <div className="overflow"></div>
                        <FontAwesomeIcon className="portfolio-icon" icon={faSearchPlus} />
                    </div>
                </div> 
            </div>
            <PopupboxContainer {...popupboxConfigFlappyBird} />
        </div>
    )

Additionally, here is the relevant CSS styling being used:

.portfolio-image-popubox {
  width: 45rem;
  padding: 0 0.5rem;
}

.hyper-link {
  cursor: pointer;
  color: var(--secondary-dark);
}

.hyper-link:hover {
  color: var(--primary-red);
}

@media(max-width: 768px) {
  .portfolio-image-popubox {
    width: 100%;
  }
}

@media(max-height: 640px) {
  .popupbox-wrapper {
  height: 100%;
  }
  .portfolio-image-popubox {
    width: 80%;
  }
}

You can see how it currently looks here. Do you have any suggestions on how to make the entire image fit on the screen?

Thank you for your assistance.

Answer №1

Did you attempt setting the image's size to width:100%;, or applying the w-100 bootstrap class? If that doesn't work, consider including display:block; or display:inline-block; in the img tag as well.

If the image is already at 100% width, try using the object-fit property with either object-fit: contain; or object-fit: cover;

UPDATE:

Based on some preliminary tests conducted on the provided website, adding this CSS should resolve the issue.

.portfolio-image-popupbox {
    width: 100%;
}

screenshot: https://ibb.co/pXjLwHf

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

Updating subdata in an array using Reactjs handleChange

I am facing an issue with my handleChange function. While I can easily change data in the same directory without any problem, I'm struggling to update sub-data. I would like to find a clean solution for this without having to add extra functions withi ...

Tips for implementing dynamic routing in React

Currently, I am in the process of building a dashboard application with React. One aspect that is giving me trouble is understanding how to utilize react-router. Can someone provide guidance on utilizing dynamic routes and rendering components? Within my ...

Need to update React textarea with value that is currently set as readonly

In my React application, I have a textarea that is populated with a specific value. My goal is to allow this textarea to be updated and then submit the form in order to update the corresponding row in the database. <textarea id="description" className= ...

Swap out the traditional submit button on your form with a stylish Font Awesome

Can anyone assist with replacing the submit button with a Font Awesome icon? I've tried it myself, but the icon is not displaying on the button. Here is what I have attempted so far: <form action="{{route('destroycourse', $course->id) ...

Is there a way to remove the end date feature in ReactJS?

I have a calendar feature on my website for setting campaign dates. I want users to be able to see all the available dates for the start of the campaign, but once they select a starting date, the end date cannot be before today's date. For example, if ...

When implementing MUI X DataGrid, only one row appears at a time when paginating through the

I am currently utilizing MUI X Data Grid v5 along with Tanstack React Query v4. My objective is to implement pagination on my Datagrid component. Initially, when the page loads, the grid fetches and displays the data as expected. However, an issue arises w ...

Weird Chrome behaviors with CSS3 animations

I have been working on a CSS3 animation that involves rotating a div with an image in the background. My goal is to have the same animation play at a different speed when the user hovers over the element. Here is the code snippet I have been using: .roc ...

NextJs conveniently removes query strings from headers automatically

Whenever I access the following url , the query parameter fpr=marten48 is automatically removed from the header. How can I stop this from happening? ...

How can I enable the right click function to close a Modal in Material-UI?

Is there a way to close a Menu (or more specifically, a Popover) with a right click or any mousedown event? I came across the documentation that discusses this: https://material-ui.com/components/menus/#MenuListComposition.js After some cleanup, I was ab ...

What steps should be taken to ensure that the onmouseover and onmouseout settings function correctly?

The Problem Currently, I have a setup for an online store where the shopping cart can be viewed by hovering over a div in the navigation menu. In my previous prototype, the relationship between the shoppingTab div and the trolley div allowed the shopping ...

Issue with Chrome not triggering onMouseEnter event when an element blocking the cursor disappears in React

Important Note: This issue seems to be specific to Chrome Currently, React does not trigger the onMouseEnter event when a blocking element disappears. This behavior is different from standard JavaScript events and even delegated events. Below is a simpli ...

Are you familiar with utilizing social share buttons in NEXTJS?

I have been encountering issues with the social share button in my Next.js project using the package https://www.npmjs.com/package/react-share. The share count for platforms like Facebook, LinkedIn, and Twitter is not displaying properly and I am unable ...

Issue with Angular 6 Animation not showing up

Looking to incorporate an animation spinner into my Angular app Found this spinner example: https://codepen.io/z-/pen/OPzNLz spinner.component.html import { Component, OnInit } from '@angular/core'; @Component({ selecto ...

Experiencing Troubles with Design Customization in Flowbite-React

I'm currently diving into the world of theme customization with Flowbite-React by following their guide on creating a reusable component with a custom theme. Unfortunately, I seem to be encountering some difficulties in getting it to function properly ...

Ensuring a consistent folder structure in ReactJS even post-build

Today I encountered a strange issue while building a ReactJS app. After checking in the browser, the built files are exposing my raw folder structure, which should not happen. https://i.sstatic.net/wrT1G.png Some solutions mentioned on StackOverflow incl ...

Using CSS to style the last element in a set of dynamic content

I am currently working on targeting the last element in a dynamically generated content set. For instance, here is an example of how the generated content appears: <div class="block"> <div class="block-inner"> <div class="box"> ...

Converting axios response containing an array of arrays into a TypeScript interface

When working with an API, I encountered a response in the following format: [ [ 1636765200000, 254.46, 248.07, 254.78, 248.05, 2074.9316693 ], [ 1636761600000, 251.14, 254.29, 255.73, 251.14, 5965.53873045 ], [ 1636758000000, 251.25, 251.15, 252.97, ...

What is the reason behind HTML comment delimiters failing to function within HTML style tags?

Currently, I am utilizing CSS and HTML in my project. To implement styles, I am utilizing both an external stylesheet as well as a "style" element within the HTML to override certain styles. However, I have encountered an issue. When I insert an HTML comm ...

Allowing input fields to accept decimal numbers

I am currently facing an issue with an input field that is set to type=number, which does not allow for decimal numbers. However, I need to enable users to input decimal numbers but haven't been able to make it work. Would using regex be a possible so ...

Yep, implementing conditional logic with the `when` keyword and radio buttons

I seem to be encountering an issue with my implementation (probably something trivial). I am utilizing React Hook Form along with Yup and attempting to establish a condition based on the selection of a radio group. The scenario is as follows: if the first ...