Disregard the CSS styling within the modal window

Currently, I am working with ReactJS and ANTD. My modal has been adjusted with paddings to center-align the text, but now I want to enhance the design. Here is the desired look: https://i.stack.imgur.com/qef7n.png

This is how it appears at the moment: https://i.stack.imgur.com/5QsAv.png

CSS:

modalStyle {
   padding: 100px 50px
}

index.js

const styling ={
design:{
        background: "#FFFFFF",
        width: "400px",
        height: "30px",
        margin: "40px 50px 40px 0px !important"
    }
}

const Modal = props => {
return (

        <Modal
            className={"modalStyle"}

        > 
            <div style={styling.design}> </div>
        </Modal>
)

Answer №1

To offset the padding from the modal container, consider incorporating a negative left margin in your inner div.

const styling ={
design:{
        ...otherStyles,
        margin: "40px 50px 40px -50px !important"
    }
}

By applying this adjustment, the contents will extend all the way to the left edge. If you prefer the text to be positioned further in, you can also include padding on the div.

const styling ={
design:{
        ...otherStyles,
        margin: "40px 50px 40px -50px !important",
        padding: 100px 50px,
    }
}

For reference, here is a demonstration of an inner div exceeding the margins of a modal https://codesandbox.io/s/counter-act-padding-in-child-o5y7z

In my opinion, utilizing `:before` and `:after` pseudo elements would be the optimal approach for achieving this effect. I can provide an example showcasing that method as well.

Answer №2

If you're looking to achieve this, I suggest utilizing flexbox,

//Component

<div className="modal">
    <div className="modal-bar" />
    <div className="modal-text">
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
      eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
      minim veniam.
    </div>
    <div className="modal-bar" />
  </div>

//CSS

   .modal {
      width: 80%;
      height: 50vh;
      display: flex;
      flex-flow: column;
      margin: auto;
      background: #0075cb;
      border: 1px solid #0075cb;
      border-radius: 50px;
      padding: 50px 0;
      justify-content: space-between;
    }
    .modal-bar {
      height: 50px;
      width: 100%;
      background: white;
    }

    .modal-text {
      padding: 50px;
      text-align: left;
    }

I've set up a sandbox with the same demo, 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

What is the best way to display a placeholder image in a React project when the image URL is

Here is the code snippet I'm working with: import React, { Component } from 'react'; import './App.css'; class App extends Component { state = { loaded: false, error: false } onImageLoad = () => { this.setS ...

Having trouble with create-react-app? Seeking assistance from the community! Your help would be greatly

Recently attempted to build my first React app, but it seems like React is not in the mood to greet me. After installing Node.js and create-react-app, double-checking their versions to ensure proper installation, I proceeded to create the React app using t ...

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 ...

Expanding rows on a Sortable Table Material UI table in React upon clicking

I've been working on creating a user-friendly table using Material UI and React that allows for sorting. The main functionality I'm aiming to achieve includes: A sortable table with 4 initial rows Adding an additional 4 rows below the default d ...

text box with an immobile header

As the browser window size decreases, the layout changes. However, when scrolling down, the search text box moves up and is no longer visible due to its lack of fixation. How can I make the search text box stay fixed as I scroll down? I tried implementing ...

What is the reason for choosing to use the render method outside of components instead of within

I built a component that includes the following code: interface Props { email: string; } const getErrorMessage = (payload: any) => { if (typeof payload.data === 'string') { return payload.data; } else if (payload.data && &apo ...

Clicking will cause my background content to blur

Is there a way to implement a menu button that, when clicked, reveals a menu with blurred content in the background? And when clicked again, the content returns to normal? Here's the current HTML structure: <div class="menu"> <div class=" ...

Utilize the Autocomplete feature from Material UI to dynamically generate tags based on user input

Is there a way to allow users to both select tags from a dropdown list and manually create new tags by typing them in separated by commas? To implement this functionality, I utilized the useState hook with an array. const [tags, setTags] = useState([]); ...

Automatic completion of absolute paths in VS Code with the ability to click and view definitions through the configuration file js/tsconfig.json

In order to ensure that absolute paths function correctly, I have found that there are two key steps involved: the compilation process and configuring the code editor. I successfully managed the compilation aspect by utilizing babel-plugin-module-resolver ...

Sustaining component state in NextJS applications

I am facing an issue with my NextJS app where I have two distinct layouts for landscape and portrait modes. The parent page structure is as follows: <NavWrapper> <MyPage> </NavWrapper> The NavWrapper component handles the layout based on ...

Searching dynamically using class names with JQuery

I am seeking to create a dynamic search input based on the class names within the span tags. However, I am struggling with displaying the class name that I have identified. My goal is to show the class names that match the entered value in the input on the ...

Ways to expand the width of mat-dialog-actions component in Angular 8

Is there a way to make the cancel and save buttons in the dialog window take up the entire available space? If anyone has any suggestions on how to achieve this, please let me know! ...

List that spans the entire width of the browser, with text limited to a maximum width

I've encountered an issue with a full-width list in my browser. It has a background color that changes when hovered over. However, I want the text within each li element to have left-aligned alignment, a maximum width, and equal left and right margins ...

Efficient Django Template: Accurate Conversion of Values through Dictionary Searching

I have an object with an attribute that has specific choices defined in its class: class StashURLJobRequest(models.Model): STATUS_CHOICES = ((0,"Requested"),(1,"Done"),(2,"Failed")) url = models.URLField() created = models.DateTimeField(auto_n ...

npm script for quickly generating React components

Can a script be written in package.json to generate a new folder with a name provided as an argument 'MyComponent' (for instance) and also create four files with the same name: MyComponent.js MyComponent.css MyComponent.test.js README.md "s ...

Make sure to employ Bootstrap's justify-content-between and stack-to-horizontal col correctly

I am currently working on a responsive form that contains 1 label, 1 input field, and 5 buttons. Both the buttons and the input field are located under col-8. The positioning I aim for the buttons is as follows: They should start below and align with ...

[Babel]: The option foreign.Children is not recognized

I encountered an error while building with the following script: webpack --colors --progress --watch --config --jsx-loader webpack.config.js Below is the content of my package.json file: { "dependencies": { // List of dependencies here }, "dev ...

Is there a way to trigger a revalidation of a specific page from a client component in NextJS?

The issue Currently, I am in the process of developing a website that utilizes a supabase backend. The main feature of this website is the creation of guides by users. Each guide has a unique dynamic path /guides/[id] as well as an exclusive edit page /gu ...

What are some ways to customize the styles of @devexpress/dx-react-grid-material-ui?

How can I customize the styles of TableSummaryRow from the '@devexpress/dx-react-grid-material-ui' library? Current Situation: I have a component that displays a table using the '@devexpress/dx-react-grid-material-ui' library, and at t ...

Issue with responsive design: Media queries not applying max-width

GOAL I want the content of my page to adjust to screen sizes that are smaller than 600px wide. ISSUE When using the responsive tool in Chrome, preset screen sizes like iPhone X do not apply media queries properly. Even manually adjusting the screen size ...