Positioning elements using CSS Flexbox within the body of a modal dialog box

Hey there! I'm trying to achieve a specific style using flexbox, but I'm having trouble with placing the modal close button on top of the image. If anyone has any tips or guidance, I would greatly appreciate it! Here's what I have so far: https://i.sstatic.net/Ifc8x.jpg

Below is the code snippet for the bootstrap modal dialog box that I'm working on:

<Modal show={this.props.show} onHide={() => this.props.onHide()}
                >
                    <Modal.Body className ="modal-body">
                    
                    <div className = "data-container">
                    <div class="callout" data-closable>
                        <button class="close-button" onClick={() => this.props.onHide()}  aria-label="Dismiss alert" type="button" data-close>
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                        {this.props.data} 
                    </div>
                    </Modal.Body>
                </Modal>

And here is the CSS that I have been working with:

.modal-dialog {
  display: flex;
  max-width: 800px;
  height:auto;
  flex-direction:column;
  justify-content: center; 
  padding-top:150px;
  margin: auto;
} 

.modal-content {
  overflow: hidden;
  border:none;
  justify-content: center;
  margin:auto;
}

.modal-body {
  display: flex;
  flex-direction:column;
  align-items: center;
  justify-content: center;
  background-color:rgb(221, 221, 221);
  padding: 2px;
}
.callout {
  display:flex;
  border: none;
  display: block;
  margin-left:47rem;
}
.close-button {
  border: none;
  background-color:rgb(221, 221, 221);
  color:red;
  margin:auto;
  font-size:50px;
} 

If anyone can provide some assistance, it would be greatly appreciated. Thank you! ✌️

Answer №1

To begin, make sure to define the positioning of your parent containers by setting position to relative

.container-box {
  position: relative;
}

Next, apply absolute positioning and align it to the right side of the container that holds your close button

.notification-box {
  position: absolute;
  right: 0;
}

Check out the live demonstration here

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

I've been attempting to display information from a mongodb server onto my react application, but unfortunately, it's just not functioning as expected

Below is the error message from the console log: An Error was encountered: Objects are not valid as a React child (found: object with keys {_id, inputText, __v}). If you intended to render a collection of children, please use an array instead. at throwOnIn ...

Struggling with displaying nested JSON data in React components

I have a nested JSON structure running on my local server, and I'm using React to practice displaying this nested data. Currently, I am focusing on showing the day and the available time slots for that day. I have managed to extract the "days" (mon, t ...

Is the getInitialProps function in document.js executed on the server side or client side?

Does the getInitialProps function run only on the server, or client, or both? class MyDocument extends Document { static async getInitialProps(ctx: DocumentContext) { const initialProps = await Document.getInitialProps(ctx); console.log("docu ...

Comparing currency to double in handlebars: a comprehensive guide

I've been working with Handlebars.js and encountered an issue when trying to compare product prices above $35. The problem arises from the fact that prices are stored as "$54.99" which gets treated as 0 when compared to a number. How can I effectively ...

Is there a way to hide the blinking cursor at the conclusion of the animation after 3 seconds?

I've been working on this HTML snippet <div class=typewriter> <h1>Lorem Ipsum</h1> </div> and included some CSS styles as well .typewriter { display: inline-block; } .typewriter h1 { overflow: hidd ...

What is the best method for setting the height of an empty inline block element to match the line height of its container?

By default, inline-block elements adjust their height based on the container's line height only when they have content. However, I've noticed that empty or whitespace-only inline block elements default to a height of 0 (observed in Firefox). Is ...

Highlighting a specific list item dynamically without affecting its nested children

While I have come across similar questions, they don't quite address the specific issue I'm facing. My current project involves creating a keyboard-accessible tree widget. My goal is to apply a background color to the selected list item without ...

Using Laravel to connect custom fonts

After previously discussing and experimenting with linking custom font files in Laravel, I encountered an issue where the fonts were not displaying correctly on my website. Due to Laravel's router, directly linking to font files in CSS was posing a ch ...

`Why Mui Datepicker always shows the wrong date?`

Currently utilizing the Mui Datepicker library from @mui/x-date-pickers/DatePicker. Below is a snippet of my code <LocalizationProvider dateAdapter={AdapterDateFns}> <DatePicker inputFormat="MM/dd/yy" value={date} minDate= ...

Is the sliding navigation glitching due to the video background?

Currently, I am in the process of developing a website with a captivating full-page video background. The nav menu gracefully slides out from the left side using jQuery UI when users scroll down to view the site's content. To view the work-in-progres ...

The scroll bar remains hidden even though there are additional elements waiting to be displayed

I am currently utilizing asp.net along with entity framework 4 On my page, I have three tabs structured like this: The Challenge I'm Facing The issue I am encountering is that the browser fails to display a scrollbar even when there are over 150 ro ...

I am unable to make any changes to the CSS in the WordPress code that is already integrated

I have created a static web page to serve as my primary homepage. The page is built using HTML and CSS, with some PHP code pulled from My WordPress integrated into it. One of the functionalities I've added is to display the three most recent posts on ...

Adjust the appearance attribute of FormField within the designated theme

Currently, I am collaborating within an NX Monorepo and utilizing a shared ui-components library that extends the capabilities of Angular Material Components. Despite using different themes for various applications, I am aiming to incorporate appearance=&a ...

Styling with CSS: Changing the Background Color of Text

Looking for a solution to apply line-height to text without affecting the background color? Check out the code snippet below and share your ideas if you have any. Thanks! .nb-semnox-impact-grid { display: block; font-size: 6 ...

Tips for positioning buttons using HTML and CSS

Looking for some help with my HTML page design. I have a few buttons that I want to style like this: https://i.stack.imgur.com/3UArn.png I'm struggling with CSS and can't seem to get them positioned correctly. Currently, they are displaying "bel ...

What is the best way to align a div in the middle of an input-group div?

When dealing with a nested div, where the parent div is styled with an input-group class, my goal is to have the nested div centered within the available line or on the next free line space. This is the desired layout I want to achieve regardless of the n ...

Is it possible to activate the onChange function even when the input value is automated?

I am using a Form.Input element <Form.Input fluid required label="First name" placeholder="Jose" name="firstName" value={ _.isNil(selectedProfile) ? firstName : selectedProfile.first_name } onChange={this.onCustomerFieldUpdate} /> In my code, I am ...

Guide for manually initiating the mouseleave event on a smartphone or tablet

Is there a way to change the color of a link to orange when it's hovered over? On mobile devices, the link should turn orange when touched and stay that way until the user clicks away. I'd like to manually trigger the mouseout event to remove th ...

The input field cannot be accessed via touch on mobile devices

<div class="form-group row pswrd" style="padding: 0px 10px"> <div id="email" class="col-md-12 col-xs-12"> <input type="password" class="form-control c_fname" id="c" #pswd name="password" placeholder="password" [(ngModel)]="user.passwor ...

Can a Chrome extension display a webpage in a separate window using only JS, HTML, and CSS?

I am currently working on creating a custom Google Chrome extension. My goal is to have a small window appear when the user clicks on the extension button, without using window.open or traditional pop-ups, to display a specific web page. I have a basic un ...