Looking to minimize the unnecessary spaces within your html tags?

I encountered an issue while creating my custom toast notification in React. There are unnecessary gaps between the elements, causing the size to be larger than intended.
React Code

import React from 'react'
import './CustomToast.css'
import {BsFillBellFill} from 'react-icons/bs'
import {ImCross} from 'react-icons/im'
function useCustomToast(title,message){
    const close = () =>{
        alert('closed')
    }
    return(
        <div className="notification">
            <div className="topPart">
                <div className="iconPoision">
                    <p><BsFillBellFill/></p>
                </div>
                <div className="notifiData">
                    <p><b>{title}</b></p>
                </div>
                <div className="crossPosition">
                    <p><button onClick={close} className="closeButton"><ImCross/></button></p>
                </div>
            </div>
            <div className="downPart">
                <p>{message}</p>
            </div>
        </div>
    )
}

The Code's CSS

.notification{
    top: 5px;
    right: 5px;
    background-color: rgba(0, 255, 234, 0.726);
    color: rgb(255, 255, 255);
    box-shadow: 2px 2px rgba(255, 255, 255, 0.562);
    box-sizing: border-box;
    position: fixed;
    border-radius: 5px;
    display: grid;
    grid-row-gap:2px;
    grid-template-rows: auto auto;   
}
.topPart{
    display: grid;
    grid-column-gap: 2px;
    grid-template-columns: 22px auto 25px;
}
.downPart{
    display: grid;
    grid-column: auto;
    grid-template-columns: auto;
    text-align: right;
}
.notifiData{
    text-align: left;
}
.iconPoision{
    text-align: center;
}
.closeButton{
    background-color: transparent;
    border: transparent;
    color: rgb(255, 255, 255);
    transition:ease-out;
}
.crossPosition{
    text-align: center;
}

By removing the spaces between the elements, the notification panel will appear smaller and more compact, resembling a typical notification.There is a noticeable amount of empty space between the top and bottom rows. https://i.sstatic.net/VTAuV.png

Answer №1

To customize your toast styling, simply update the './CustomToast.css' file as required.

div { 
  padding: 0;
  margin: 0;
}

Feel free to replace the 'div' tag with any other tag like span, article, etc.

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

Ensuring the Sticky Table Header Moves Alongside Horizontal Scroll

I've been working with an HTML table that has a sticky header, meaning the header stays in place as the table scrolls vertically. However, I'm facing an issue where I need the header to move along with the horizontal scroll, but remain fixed ver ...

Issues with fonts in Google Chrome Version 32.0.1700.76 m

After recently updating my Google Chrome browser, I noticed that some of the fonts are not displaying correctly. Interestingly, they appear fine on other browsers, but the issue only seems to occur in Chrome v32.0.17...76 m. The fonts I used were "Open Sa ...

Tips for Omitting Children <li> from CSS Design

I'm currently working in SharePoint Designer and facing an issue with custom bullets in my list. My goal is to apply a custom bullet on the parent li elements (Desc 1 and Desc 2), but unfortunately, it's also being applied to all the children li ...

Is there a way to make the iOS Safari address bar shrink when scrolling, all while having a flexbox sticky footer inside a container?

I have implemented a standard flexbox sticky footer solution in my code: <body> <div class="wrapper"> <div class="header">Page Header</div> <div class="body"> <div class="b ...

The CreateContext hook is preventing any other components from being displayed

My components are not rendering when using createContext. I have tried removing the context and everything works fine, but I need it for certain components. Here is my code: App.js Components- - import "./App.css"; import Nav from "./Nav&q ...

The customary scroll bar located to the right side of the screen

I'm struggling to create a common scrollbar for both the left navigation div and right content div on a simple page, but all my attempts have failed. No matter what I try, the scrollbar only works for the content div. Is there any way to make them sha ...

Develop and oversee the administration of Google Forms using a NodeJS application

I have a unique use-case scenario where I am developing a desktop application using Electron and React. In this app, users should be able to create a Google Form directly through the interface that I provide, without having to open a separate web page if p ...

Toggle Checkbox Group for Both Multiple and Single Selection Options

Need help with a function to enable only one checkbox for single selection or multiple checkboxes for multiple selection. Use MultipleCheckbox(0) for single selection or MultipleCheckbox(1) for multiple selection. function MultipleCheckbox(elem){ i ...

Having trouble accessing req.files with Multer, Express, and React

I am experiencing difficulties in retrieving req.files as it always appears to be undefined. I am utilizing multer, and I have seen other posts where they attempt using upload.single("input name"). However, that also did not work. Controller const db = re ...

Choose an image to be displayed at either full width or full height, depending on which dimension is reached first

I have a query regarding resizing an image within a div to either 100% width or 100% height of the containing div. Despite setting max-height and max-width to 100% as recommended here, I still encounter overflow issues without wanting to crop the image usi ...

Encountering a 404 error while trying to refresh the page in a React App hosted on Her

After deploying a React App on Heroku, I encountered a frustrating issue: every time a page is refreshed, a 404 error appears, such as: Cannot GET /create In my search for a solution, I came across a related issue: Question about 404 with React Router ...

Three divs arranged side by side with responsive design for mobile viewing

This code generates 3 divs for display. However, I am looking to optimize them for mobile devices. What steps can I take to accomplish this? Currently, the divs are oriented to the left and are not visible on a mobile device. I would like them to display ...

Displaying text and concealing image when hovering over a column in an angular2 table

I am currently using a table to showcase a series of items for my data. Each data entry includes an action column with images. I would like to implement a feature where hovering over an image hides the image and reveals text, and vice versa (showing the im ...

navigating through a specific section of a data chart

I need the first column of a table to stay fixed while the rest of the columns scroll horizontally. Here's the code I have: <div id="outerDiv"> <div id="innerDIv"> <table> <tr><td>1</td><t ...

Designing a Curved Stepper Component in the Shape of an S

I've been attempting to create a custom stepper component with an S-curve shape using React, but so far I haven't been successful. I even tried utilizing the MUI Stepper component and experimented with pure HTML and CSS, but couldn't achieve ...

Ways to activate side-to-side scrolling?

Here on this specific page, I am looking to showcase the SPECIAL and RECOMMENDED sections together in a single line with horizontal scrolling. This is my current CSS: .box-product { width: 100%; overflow: auto; } I have attempted implementing it like th ...

Developing websites using Bootstrap 4 and React, with the added feature of a

Having trouble making a pre/code block multiline in a React 16 app created with create-react-app and Bootstrap 4. I've followed the Bootstrap documentation on code blocks, but it doesn't seem to work in my environment. The code works fine when t ...

Utilizing Bootstrap and flexbox to create a card: repositioning the image to the left or right

Currently, I am attempting to construct a card layout using Bootstrap 4 with flexbox enabled. The image below depicts my current implementation, which is functioning as expected. https://i.sstatic.net/huXvo.jpg Here is the HTML structure: <section> ...

React-Native Error: Invalid element type detected

While attempting to run my React Native app on my iPhone using Expo, I encountered an error displayed in a red background area. Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite ...

The argument labeled as 'State' cannot be assigned to a parameter labeled as 'never'

I've recently delved into using TypeScript with React. I attempted to incorporate it with the React useReducer hook, but I hit a roadblock due to an unusual error. Below is my code snippet: export interface ContractObj { company: string; ...